Compare commits
7 Commits
57c42bcc41
...
EpisodeGro
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b830659bc | |||
| c423d8f3ed | |||
| 25b214c0d7 | |||
| 310978054d | |||
| c1103564bb | |||
| 80dc743835 | |||
| 5a0ffdad1e |
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.11.35303.130
|
VisualStudioVersion = 17.11.35303.130
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimeAnnouncer", "AnimeAnnouncer\AnimeAnnouncer.csproj", "{B6D808BF-954E-48C8-A37E-62A8AA4E06C0}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnimeAnnouncer", "AnimeAnnouncer\AnimeAnnouncer.csproj", "{B6D808BF-954E-48C8-A37E-62A8AA4E06C0}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MassTorrentAdd", "MassTorrentAdd\MassTorrentAdd.csproj", "{AE94FFAE-8D5B-46EF-BC7C-48510F0F7F04}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -15,6 +17,10 @@ Global
|
|||||||
{B6D808BF-954E-48C8-A37E-62A8AA4E06C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B6D808BF-954E-48C8-A37E-62A8AA4E06C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{B6D808BF-954E-48C8-A37E-62A8AA4E06C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B6D808BF-954E-48C8-A37E-62A8AA4E06C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{B6D808BF-954E-48C8-A37E-62A8AA4E06C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B6D808BF-954E-48C8-A37E-62A8AA4E06C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AE94FFAE-8D5B-46EF-BC7C-48510F0F7F04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AE94FFAE-8D5B-46EF-BC7C-48510F0F7F04}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AE94FFAE-8D5B-46EF-BC7C-48510F0F7F04}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AE94FFAE-8D5B-46EF-BC7C-48510F0F7F04}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -13,12 +13,17 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
|
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
|
||||||
<PackageReference Include="TMDbLib" Version="2.2.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="appSettings.json">
|
<None Update="appSettings.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="TMDbLib">
|
||||||
|
<HintPath>..\Libraries\TMDbLib.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -196,10 +196,44 @@ namespace AnimeAnnouncer
|
|||||||
|
|
||||||
|
|
||||||
if(latestSeasonNumber != int.Parse(season))
|
if(latestSeasonNumber != int.Parse(season))
|
||||||
|
{
|
||||||
|
var titleSeason = int.Parse(season);
|
||||||
|
bool seasonOverride = false;
|
||||||
|
if(latestSeasonNumber ==1 && titleSeason > 1 && latestEpisodeNumber > 3)
|
||||||
|
{ //Check episode groups to see if this is a single-season default show
|
||||||
|
var showResult = await tmdbClient.GetTvShowAsync(supposedShowId, TMDbLib.Objects.TvShows.TvShowMethods.EpisodeGroups);
|
||||||
|
var seasonEpisodeGroup = showResult.EpisodeGroups.Results.FirstOrDefault(eg => eg.Name == "Seasons");
|
||||||
|
if(seasonEpisodeGroup != null)
|
||||||
|
{ //Evaluate using new episode group
|
||||||
|
var targetEpisodeGroup = await tmdbClient.GetTvEpisodeGroupsAsync(seasonEpisodeGroup.Id);
|
||||||
|
if(targetEpisodeGroup != null)
|
||||||
|
{
|
||||||
|
var targetSeason = targetEpisodeGroup.Groups.FirstOrDefault(g => g.Order == titleSeason);
|
||||||
|
if(targetSeason != null)
|
||||||
|
{ //Episode_Type isn't making it with the current client, guess based on ordering
|
||||||
|
var targetFinale = targetSeason.Episodes.OrderByDescending(g => g.Order).FirstOrDefault(e => e.EpisodeType.Equals("finale", StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
//Confirm it's aired within the last week
|
||||||
|
if(targetFinale != null && targetEpisodeGroup.Groups.OrderByDescending(g => g.Order).FirstOrDefault() == targetSeason)
|
||||||
|
{ //confirm the episode is marked as finale and that this season is the latest one in the episode group
|
||||||
|
Console.WriteLine($"!!Choosing S{titleSeason}E{targetFinale.Order + 1} for finale using episode groups");
|
||||||
|
cachedShow.LatestSeasonNumber = latestSeasonNumber = titleSeason;
|
||||||
|
cachedShow.LastEpisodeNumber = latestEpisodeNumber = targetFinale.Order + 1;
|
||||||
|
seasonOverride = true;
|
||||||
|
_ = tmdbCache.SetCacheItem($"ShowCache-{title}", cachedShow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Console.WriteLine("Could not find a finale episode.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!seasonOverride)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Failing release due to TMDB's season number {latestSeasonNumber} not matching title season {season}");
|
Console.WriteLine($"Failing release due to TMDB's season number {latestSeasonNumber} not matching title season {season}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(latestEpisodeNumber != int.Parse(episode))
|
if(latestEpisodeNumber != int.Parse(episode))
|
||||||
{
|
{
|
||||||
@@ -259,12 +293,17 @@ namespace AnimeAnnouncer
|
|||||||
String overview = !String.IsNullOrWhiteSpace(cachedShow.LatestSeasonOverview) ? cachedShow.LatestSeasonOverview : cachedShow.Overview ?? String.Empty;
|
String overview = !String.IsNullOrWhiteSpace(cachedShow.LatestSeasonOverview) ? cachedShow.LatestSeasonOverview : cachedShow.Overview ?? String.Empty;
|
||||||
if (!String.IsNullOrWhiteSpace(overview))
|
if (!String.IsNullOrWhiteSpace(overview))
|
||||||
{
|
{
|
||||||
statusText += $"Overview: {overview}";
|
statusText += $"{overview}";
|
||||||
}
|
}
|
||||||
if(statusText.Length >= 500)
|
String anidbLink = $"{Environment.NewLine}https://anilist.co/search/anime?search={cachedShow.Title.Replace(" ", "%20")}";
|
||||||
|
int linkLength = anidbLink.Length;
|
||||||
|
|
||||||
|
if (statusText.Length + linkLength + 3 >= 500)
|
||||||
{
|
{
|
||||||
statusText = statusText[..497] + "..";
|
statusText = statusText[..(500 - (linkLength + 3))];
|
||||||
}
|
}
|
||||||
|
statusText += $"..{anidbLink}";
|
||||||
|
|
||||||
_ = mastodonClient.PublishStatus(statusText,
|
_ = mastodonClient.PublishStatus(statusText,
|
||||||
Visibility.Public, mediaIds: attachment != null ? new String[] { attachment.Id } : null);
|
Visibility.Public, mediaIds: attachment != null ? new String[] { attachment.Id } : null);
|
||||||
|
|
||||||
|
|||||||
28
MassTorrentAdd/Dockerfile
Normal file
28
MassTorrentAdd/Dockerfile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||||
|
|
||||||
|
# This stage is used when running from VS in fast mode (Default for Debug configuration)
|
||||||
|
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
|
||||||
|
USER app
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
||||||
|
# This stage is used to build the service project
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["MassTorrentAdd/MassTorrentAdd.csproj", "MassTorrentAdd/"]
|
||||||
|
RUN dotnet restore "./MassTorrentAdd/MassTorrentAdd.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/MassTorrentAdd"
|
||||||
|
RUN dotnet build "./MassTorrentAdd.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
# This stage is used to publish the service project to be copied to the final stage
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "./MassTorrentAdd.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "MassTorrentAdd.dll"]
|
||||||
28
MassTorrentAdd/MassTorrentAdd.csproj
Normal file
28
MassTorrentAdd/MassTorrentAdd.csproj
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||||
|
<PackageReference Include="Transmission.API.RPC" Version="2.1.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="appSettings.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
109
MassTorrentAdd/Program.cs
Normal file
109
MassTorrentAdd/Program.cs
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using Transmission.API.RPC;
|
||||||
|
|
||||||
|
namespace MassTorrentAdd
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
static String watchFolder, transmissionHost, transmissionUsername, transmissionPassword, transmissionDownloadFolder, destinationFolder;
|
||||||
|
static Transmission.API.RPC.Client transmissionClient;
|
||||||
|
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
if(args.Length == 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Please provide the nyaa URL to target for download.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String url = args[0];
|
||||||
|
if (!url.Contains("rss"))
|
||||||
|
url = url + "&page=rss";
|
||||||
|
|
||||||
|
var builder = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
|
.AddJsonFile("appSettings.json", optional: false, reloadOnChange: true);
|
||||||
|
|
||||||
|
IConfigurationRoot configuration = builder.Build();
|
||||||
|
transmissionHost = configuration.GetValue<String>("transmissionURI");
|
||||||
|
transmissionUsername = configuration.GetValue<String>("transmissionUsername");
|
||||||
|
transmissionPassword = configuration.GetValue<String>("transmissionPassword");
|
||||||
|
destinationFolder = configuration.GetValue<String>("destinationFolder");
|
||||||
|
|
||||||
|
Console.WriteLine($"Using transmission server {transmissionHost}");
|
||||||
|
transmissionClient = new Transmission.API.RPC.Client(transmissionHost, null, transmissionUsername, transmissionPassword);
|
||||||
|
var sessionInformation = transmissionClient.GetSessionInformation();
|
||||||
|
if (sessionInformation == null || String.IsNullOrEmpty(sessionInformation.Version))
|
||||||
|
{
|
||||||
|
Console.WriteLine("An error occurred while receiving session information from the rpc server");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HttpClient httpClient = new HttpClient();
|
||||||
|
var response = httpClient.GetStringAsync(url).Result;
|
||||||
|
if(response == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("An error occurred while contacting Nyaa for a response");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
XDocument doc = XDocument.Parse(response);
|
||||||
|
XNamespace nyaaNS = doc.Root.GetNamespaceOfPrefix("nyaa");
|
||||||
|
var items = from item in doc.Descendants("channel").Elements("item")
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
Title = item.Element("title").Value,
|
||||||
|
Published = item.Element("pubDate").Value,
|
||||||
|
Category = item.Element(nyaaNS + "category").Value,
|
||||||
|
CategoryID = item.Element(nyaaNS + "categoryId").Value,
|
||||||
|
Size = item.Element(nyaaNS + "size").Value,
|
||||||
|
Link = item.Element("link").Value,
|
||||||
|
Description = item.Element("description").Value,
|
||||||
|
PostID = item.Element("guid").Value,
|
||||||
|
};
|
||||||
|
Console.WriteLine("Downloading ..");
|
||||||
|
foreach ( var item in items )
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{item.Title}");
|
||||||
|
}
|
||||||
|
String transmissionDirectoryName = items.First().Title.Trim();
|
||||||
|
transmissionDirectoryName = System.Text.RegularExpressions.Regex.Replace(transmissionDirectoryName, @"E\d{2,3}.*?(\d{3,4}p)", " $1");
|
||||||
|
transmissionDirectoryName = System.Text.RegularExpressions.Regex.Replace(transmissionDirectoryName, @"\s\(.*?\)$", "");
|
||||||
|
transmissionDirectoryName = destinationFolder + (destinationFolder.EndsWith("/") ? String.Empty : "/") + transmissionDirectoryName.Replace(" ", ".");
|
||||||
|
Console.WriteLine("to " + transmissionDirectoryName);
|
||||||
|
|
||||||
|
Console.WriteLine("Continue?");
|
||||||
|
if(Console.ReadKey().KeyChar != 'y')
|
||||||
|
{
|
||||||
|
Console.WriteLine("Exiting");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
var torrentData = httpClient.GetByteArrayAsync(item.Link).Result;
|
||||||
|
AddNewTorrentFileToServer(torrentData, transmissionDirectoryName);
|
||||||
|
}
|
||||||
|
Console.WriteLine("Completed");
|
||||||
|
}
|
||||||
|
private static void AddNewTorrentFileToServer(byte[] torrentFileData, String saveLocation)
|
||||||
|
{
|
||||||
|
Transmission.API.RPC.Entity.NewTorrent newTorrent = new()
|
||||||
|
{
|
||||||
|
DownloadDirectory = saveLocation,
|
||||||
|
Paused = true,
|
||||||
|
Metainfo = Convert.ToBase64String(torrentFileData)
|
||||||
|
};
|
||||||
|
var torrentInfo = transmissionClient.TorrentAdd(newTorrent);
|
||||||
|
var seedSettings = new Transmission.API.RPC.Arguments.TorrentSettings()
|
||||||
|
{
|
||||||
|
SeedRatioLimit = 1.0,
|
||||||
|
SeedRatioMode = 1,
|
||||||
|
IDs = [torrentInfo.ID]
|
||||||
|
};
|
||||||
|
|
||||||
|
transmissionClient.TorrentSet(seedSettings);
|
||||||
|
//transmissionClient.TorrentVerify(new object[] { torrentInfo.ID });
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
MassTorrentAdd/Properties/launchSettings.json
Normal file
11
MassTorrentAdd/Properties/launchSettings.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"MassTorrentAdd": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"commandLineArgs": "https://nyaa.si/?f=0&c=1_0&q=The+Fable+VARYG"
|
||||||
|
},
|
||||||
|
"Container (Dockerfile)": {
|
||||||
|
"commandName": "Docker"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
MassTorrentAdd/appSettings.json
Normal file
8
MassTorrentAdd/appSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"transmissionUserName": "transmission",
|
||||||
|
"transmissionPassword": "",
|
||||||
|
"transmissionURI": "",
|
||||||
|
//"watchFolder": "X:\\MP3\\Upload\\current",
|
||||||
|
"destinationFolder": "/pool/torrents/Animation",
|
||||||
|
"transmissionDownloadFolder": "/mnt/download/Upload"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user