84 lines
2.4 KiB
C#
84 lines
2.4 KiB
C#
using System.Net;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using ConsoleApp1;
|
|
using TMDbLib.Client;
|
|
|
|
|
|
|
|
List<Tv> BuildShows(string basePath)
|
|
{
|
|
var shows = new List<Tv>();
|
|
var showPaths = Directory.GetDirectories(basePath);
|
|
|
|
foreach (var showPath in showPaths)
|
|
{
|
|
var sessions = new List<Session>();
|
|
|
|
var sessionPaths = Directory.GetDirectories(showPath);
|
|
|
|
foreach (var sessionPath in sessionPaths)
|
|
{
|
|
var episodeIds = new List<int>();
|
|
var episodePaths = Directory.GetFiles(sessionPath);
|
|
|
|
HashSet<int> episodes = new HashSet<int>();
|
|
foreach (var episodePath in episodePaths)
|
|
{
|
|
var matches = Regex.Matches(episodePath, @".*S\d+E(\d+).*");
|
|
if (matches.Count == 0) continue;
|
|
var episode = int.Parse(matches[0].Groups[1].Value);
|
|
episodes.Add(episode);
|
|
}
|
|
|
|
var session = new Session
|
|
{
|
|
id = int.Parse(Path.GetFileName(sessionPath).Replace("Season ", "")),
|
|
episodes = episodes.ToList()
|
|
};
|
|
|
|
sessions.Add(session);
|
|
}
|
|
|
|
shows.Add(new Tv
|
|
{
|
|
name = Path.GetFileName(showPath),
|
|
sessions = sessions
|
|
});
|
|
}
|
|
return shows;
|
|
}
|
|
|
|
|
|
var tvs = BuildShows(@"\\192.168.31.10\media\autobgm");
|
|
|
|
var client = new TMDbClient("991107af25913562cfa06622a52873e1", proxy: new WebProxy("http://127.0.0.1:7897"));
|
|
|
|
StringBuilder output = new StringBuilder();
|
|
|
|
int i = 0;
|
|
foreach (var tv in tvs)
|
|
{
|
|
Console.WriteLine($"{++i}/{tvs.Count}");
|
|
var match = Regex.Match(tv.name, @"(.*) \((\d{4})\)");
|
|
var title = match.Groups[1].Value;
|
|
var year = int.Parse(match.Groups[2].Value);
|
|
var result = await client.SearchTvShowAsync(title, firstAirDateYear: year);
|
|
var info = result.Results.FirstOrDefault();
|
|
foreach (var session in tv.sessions)
|
|
{
|
|
var sessionInfo = await client.GetTvSeasonAsync(info.Id, session.id);
|
|
foreach (var episode in sessionInfo.Episodes)
|
|
{
|
|
if (DateTime.Now.AddDays(-7) < episode.AirDate) continue;
|
|
if (!session.episodes.Contains(episode.EpisodeNumber))
|
|
{
|
|
output.AppendLine($"{title} 的第 {session.id} 季少了第 {episode.EpisodeNumber} 集");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
File.WriteAllText("缺少的级数.txt", output.ToString());
|
|
|