Compare commits
7 Commits
MassTorren
...
25b214c0d7
| Author | SHA1 | Date | |
|---|---|---|---|
| 25b214c0d7 | |||
| 310978054d | |||
| c1103564bb | |||
| 57c42bcc41 | |||
| 7bc2ef89a2 | |||
| 2e48daae3a | |||
| 5937ddcbd8 |
@@ -8,12 +8,12 @@ namespace AnimeAnnouncer.Cache
|
|||||||
|
|
||||||
public int LatestSeasonNumber { get; set; }
|
public int LatestSeasonNumber { get; set; }
|
||||||
public int LastEpisodeNumber { get; set; }
|
public int LastEpisodeNumber { get; set; }
|
||||||
public string? PosterPath { get; internal set; }
|
public string? PosterPath { get; set; }
|
||||||
public string? BackdropPath { get; internal set; }
|
public string? BackdropPath { get; set; }
|
||||||
public string? LatestSeasonPosterPath { get; internal set; }
|
public string? LatestSeasonPosterPath { get; set; }
|
||||||
public string? LatestSeasonOverview { get; internal set; }
|
public string? LatestSeasonOverview { get; set; }
|
||||||
public double VoteAverage { get; internal set; }
|
public double VoteAverage { get; set; }
|
||||||
public string? Overview { get; internal set; }
|
public string? Overview { get; set; }
|
||||||
public int? LatestOrdinalEpisodeNumber { get; internal set; }
|
public int? LatestOrdinalEpisodeNumber { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ using Mastonet;
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using TMDbLib.Client;
|
using TMDbLib.Client;
|
||||||
|
using TMDbLib.Objects.Authentication;
|
||||||
|
|
||||||
namespace AnimeAnnouncer
|
namespace AnimeAnnouncer
|
||||||
{
|
{
|
||||||
@@ -144,9 +145,24 @@ namespace AnimeAnnouncer
|
|||||||
|
|
||||||
latestEpisodeNumber = latestSeason.EpisodeCount;
|
latestEpisodeNumber = latestSeason.EpisodeCount;
|
||||||
|
|
||||||
|
//if nearing the end of a season, confirm it's marked with season finale
|
||||||
|
|
||||||
|
if(int.Parse(episode) >= (latestEpisodeNumber - 2))
|
||||||
|
{
|
||||||
|
var latestSeasonDetail = await tmdbClient.GetTvSeasonAsync(supposedShowId, latestSeasonNumber);
|
||||||
|
|
||||||
|
var seasonFinale = latestSeasonDetail.Episodes.LastOrDefault(e => e.EpisodeType.Equals("finale", StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
|
if(seasonFinale != null && seasonFinale.EpisodeNumber != latestEpisodeNumber)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Overriding previous finale choice of {latestEpisodeNumber} due to season detail response where it's {seasonFinale.EpisodeNumber}");
|
||||||
|
latestEpisodeNumber = seasonFinale.EpisodeNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(showResult.Seasons.Count > 1)
|
if(showResult.Seasons.Count > 1)
|
||||||
{
|
{
|
||||||
latestOrdinalEpisodeNumber = showResult.Seasons.Sum(s => s.EpisodeCount);
|
latestOrdinalEpisodeNumber = showResult.Seasons.Where(s => s.SeasonNumber != 0).Sum(s => s.EpisodeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tmdbCache != null && searchResults != null)
|
if(tmdbCache != null && searchResults != null)
|
||||||
@@ -164,8 +180,8 @@ namespace AnimeAnnouncer
|
|||||||
Overview = showResult.Overview,
|
Overview = showResult.Overview,
|
||||||
VoteAverage = showResult.VoteAverage,
|
VoteAverage = showResult.VoteAverage,
|
||||||
ShowID = supposedShowId,
|
ShowID = supposedShowId,
|
||||||
LatestSeasonNumber = latestSeason.SeasonNumber,
|
LatestSeasonNumber = latestSeasonNumber,
|
||||||
LastEpisodeNumber = latestSeason.EpisodeCount
|
LastEpisodeNumber = latestEpisodeNumber
|
||||||
};
|
};
|
||||||
_ = tmdbCache.SetCacheItem($"ShowCache-{title}", cachedShow);
|
_ = tmdbCache.SetCacheItem($"ShowCache-{title}", cachedShow);
|
||||||
Console.WriteLine($"{title} Added to cache");
|
Console.WriteLine($"{title} Added to cache");
|
||||||
@@ -193,6 +209,12 @@ namespace AnimeAnnouncer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Sometimes TMDB metadata hasn't been filled in yet
|
||||||
|
if(latestEpisodeNumber < 3)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Skipping announcement due to a low episode number");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Announce if unique
|
// Announce if unique
|
||||||
if(await tmdbCache.KeyExists($"ShowAnnounced-{supposedShowId}"))
|
if(await tmdbCache.KeyExists($"ShowAnnounced-{supposedShowId}"))
|
||||||
@@ -235,16 +257,21 @@ namespace AnimeAnnouncer
|
|||||||
//Prepare Status
|
//Prepare Status
|
||||||
String statusText = $"{cachedShow.Title} ({cachedShow.VoteAverage}/10) DUBBED has finished airing season {cachedShow.LatestSeasonNumber}! Episode {cachedShow.LastEpisodeNumber} is now available for download. {Environment.NewLine + Environment.NewLine}";
|
String statusText = $"{cachedShow.Title} ({cachedShow.VoteAverage}/10) DUBBED has finished airing season {cachedShow.LatestSeasonNumber}! Episode {cachedShow.LastEpisodeNumber} is now available for download. {Environment.NewLine + Environment.NewLine}";
|
||||||
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace MassTorrentAdd
|
|||||||
|
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
.SetBasePath(Directory.GetCurrentDirectory())
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
|
.AddJsonFile("appSettings.json", optional: false, reloadOnChange: true);
|
||||||
|
|
||||||
IConfigurationRoot configuration = builder.Build();
|
IConfigurationRoot configuration = builder.Build();
|
||||||
transmissionHost = configuration.GetValue<String>("transmissionURI");
|
transmissionHost = configuration.GetValue<String>("transmissionURI");
|
||||||
@@ -94,6 +94,14 @@ namespace MassTorrentAdd
|
|||||||
Metainfo = Convert.ToBase64String(torrentFileData)
|
Metainfo = Convert.ToBase64String(torrentFileData)
|
||||||
};
|
};
|
||||||
var torrentInfo = transmissionClient.TorrentAdd(newTorrent);
|
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 });
|
//transmissionClient.TorrentVerify(new object[] { torrentInfo.ID });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user