mirror of
https://github.com/Crunchy-DL/Crunchy-Downloader.git
synced 2026-05-19 00:11:48 +00:00
Add - Added Artist/Concerts/Music video support https://github.com/Crunchy-DL/Crunchy-Downloader/issues/67 https://github.com/Crunchy-DL/Crunchy-Downloader/issues/46 Add - Added CC support https://github.com/Crunchy-DL/Crunchy-Downloader/issues/65 Fix - "No active subscrition" text shown with funimation sub https://github.com/Crunchy-DL/Crunchy-Downloader/issues/56
87 lines
No EOL
3 KiB
C#
87 lines
No EOL
3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Specialized;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
using CRD.Utils;
|
|
using CRD.Utils.Structs;
|
|
|
|
namespace CRD.Downloader.Crunchyroll;
|
|
|
|
public class CrMovies{
|
|
private readonly CrunchyrollManager crunInstance = CrunchyrollManager.Instance;
|
|
|
|
public async Task<CrunchyMovie?> ParseMovieById(string id, string crLocale, bool forcedLang = false){
|
|
NameValueCollection query = HttpUtility.ParseQueryString(new UriBuilder().Query);
|
|
|
|
query["preferred_audio_language"] = "ja-JP";
|
|
if (!string.IsNullOrEmpty(crLocale)){
|
|
query["locale"] = crLocale;
|
|
if (forcedLang){
|
|
query["force_locale"] = crLocale;
|
|
}
|
|
}
|
|
|
|
|
|
var request = HttpClientReq.CreateRequestMessage($"{Api.Cms}/movies/{id}", HttpMethod.Get, true, true, query);
|
|
|
|
var response = await HttpClientReq.Instance.SendHttpRequest(request);
|
|
|
|
if (!response.IsOk){
|
|
Console.Error.WriteLine("Movie Request Failed");
|
|
return null;
|
|
}
|
|
|
|
CrunchyMovieList movie = Helpers.Deserialize<CrunchyMovieList>(response.ResponseContent, crunInstance.SettingsJsonSerializerSettings);
|
|
|
|
if (movie.Total < 1){
|
|
return null;
|
|
}
|
|
|
|
if (movie.Total == 1 && movie.Data != null){
|
|
return movie.Data.First();
|
|
}
|
|
|
|
Console.Error.WriteLine("Multiple movie returned with one ID?");
|
|
if (movie.Data != null) return movie.Data.First();
|
|
return null;
|
|
}
|
|
|
|
|
|
public CrunchyEpMeta? EpisodeMeta(CrunchyMovie episodeP, List<string> dubLang){
|
|
|
|
if (!string.IsNullOrEmpty(episodeP.AudioLocale) && !dubLang.Contains(episodeP.AudioLocale)){
|
|
Console.Error.WriteLine("Movie not available in the selected dub lang");
|
|
return null;
|
|
}
|
|
|
|
var images = (episodeP.Images?.Thumbnail ?? new List<List<Image>>{ new List<Image>{ new Image{ Source = "/notFound.png" } } });
|
|
|
|
var epMeta = new CrunchyEpMeta();
|
|
epMeta.Data = new List<CrunchyEpMetaData>{ new(){ MediaId = episodeP.Id, Versions = null, IsSubbed = episodeP.IsSubbed, IsDubbed = episodeP.IsDubbed } };
|
|
epMeta.SeriesTitle = "Movie";
|
|
epMeta.SeasonTitle = "";
|
|
epMeta.EpisodeNumber = "";
|
|
epMeta.EpisodeTitle = episodeP.Title;
|
|
epMeta.SeasonId = "";
|
|
epMeta.Season = "";
|
|
epMeta.ShowId = "";
|
|
epMeta.AbsolutEpisodeNumberE = "";
|
|
epMeta.Image = images[images.Count / 2].FirstOrDefault().Source;
|
|
epMeta.DownloadProgress = new DownloadProgress(){
|
|
IsDownloading = false,
|
|
Done = false,
|
|
Error = false,
|
|
Percent = 0,
|
|
Time = 0,
|
|
DownloadSpeed = 0
|
|
};
|
|
epMeta.AvailableSubs = new List<string>();
|
|
epMeta.Description = episodeP.Description;
|
|
|
|
return epMeta;
|
|
}
|
|
} |