public static bool PopulateVideo(Video l, VideoLocal v, JMMType type, int userid) { PopulateVideoEpisodeFromVideoLocal(l, v, type); List <AnimeEpisode> eps = v.GetAnimeEpisodes(); if (eps.Count > 0) { PopulateVideoEpisodeFromAnimeEpisode(l, eps[0], userid); AnimeSeries series = eps[0].GetAnimeSeries(); if (series != null) { Contract_AnimeSeries cseries = series.ToContract(series.GetUserRecord(userid), true); Video nv = FromSerie(cseries, userid); AniDB_Anime ani = series.GetAnime(); return(PopulateVideoEpisodeFromAnime(l, ani, nv)); } } return(false); }
public static string ContructVideoUrl(this IProvider prov, int userid, string vid, JMMType type) { return(prov.ServerUrl(prov.ServicePort, prov.ServiceAddress + "/Metadata/" + userid + "/" + (int)type + "/" + vid + "?excludetags=" + prov.ExcludeTags)); }
public static string ConstructVideoUrl(string vid, JMMType type, bool short_url = false) { return(APIHelper.ProperURL("__TEST__" + (int)type + "/" + vid, short_url)); }
public static string ContructVideoUrl(this IProvider prov, int userid, string vid, JMMType type) { return(Helper.ServerUrl(prov.ServicePort, prov.ServiceAddress + "/GetMetadata/" + userid + "/" + (int)type + "/" + vid)); }
public static Video MayReplaceVideo(Directory v1, AnimeSeries ser, AniDB_Anime anime, JMMType type, int userid, bool all = true) { int epcount = all ? ser.GetAnimeEpisodesCountWithVideoLocal() : ser.GetAnimeEpisodesNormalCountWithVideoLocal(); if (epcount == 1) { List <AnimeEpisode> episodes = ser.GetAnimeEpisodes(); List <VideoLocal> l = episodes[0].GetVideoLocals(); if (l.Count > 0) { Video v2 = new Video(); try { if (PopulateVideo(v2, l[0], episodes[0], ser, anime, v1, JMMType.File, userid)) { return(v2); } } catch (Exception e) { //Fast fix if file do not exist, and still is in db. (Xml Serialization of video info will fail on null) } } } return(v1); }
public static bool PopulateVideo(Video l, VideoLocal v, AnimeEpisode ep, AnimeSeries series, AniDB_Anime ani, Video nv, JMMType type, int userid) { PopulateVideoEpisodeFromVideoLocal(l, v, type); if (ep != null) { PopulateVideoEpisodeFromAnimeEpisode(l, ep, userid); if (series != null) { return(PopulateVideoEpisodeFromAnime(l, ani, nv)); } } return(false); }
private static void PopulateVideoEpisodeFromVideoLocal(Video l, VideoLocal v, JMMType type) { l.Type = "episode"; l.Summary = "Episode Overview Not Available"; l.Title = Path.GetFileNameWithoutExtension(v.FilePath); l.Key = l.PrimaryExtraKey = ServerUrl(int.Parse(ServerSettings.JMMServerPort), MainWindow.PathAddressKodi + "/GetMetadata/0/" + (int)type + "/" + v.VideoLocalID); l.AddedAt = v.DateTimeCreated.Year.ToString("0000") + "-" + v.DateTimeCreated.Month.ToString("00") + "-" + v.DateTimeCreated.Day.ToString("00") + " " + v.DateTimeCreated.Hour.ToString("00") + ":" + v.DateTimeCreated.Minute.ToString("00") + ":" + v.DateTimeCreated.Millisecond.ToString("00"); l.UpdatedAt = v.DateTimeUpdated.Year.ToString("0000") + "-" + v.DateTimeUpdated.Month.ToString("00") + "-" + v.DateTimeUpdated.Day.ToString("00") + " " + v.DateTimeUpdated.Hour.ToString("00") + ":" + v.DateTimeUpdated.Minute.ToString("00") + ":" + v.DateTimeUpdated.Millisecond.ToString("00"); l.OriginallyAvailableAt = v.DateTimeCreated.Year.ToString("0000") + "-" + v.DateTimeCreated.Month.ToString("00") + "-" + v.DateTimeCreated.Day.ToString("00"); l.Year = v.DateTimeCreated.Year.ToString(); VideoInfo info = v.VideoInfo; Media m = null; if (info != null) { if (!string.IsNullOrEmpty(info.FullInfo)) { try { m = XmlDeserializeFromString <Media>(info.FullInfo); } catch (Exception) { info.FullInfo = null; } } if (string.IsNullOrEmpty(info.FullInfo)) { VideoInfoRepository repo = new VideoInfoRepository(); MediaInfoResult mInfo = FileHashHelper.GetMediaInfo(v.FullServerPath, true, true); info.AudioBitrate = string.IsNullOrEmpty(mInfo.AudioBitrate) ? "" : mInfo.AudioBitrate; info.AudioCodec = string.IsNullOrEmpty(mInfo.AudioCodec) ? "" : mInfo.AudioCodec; info.Duration = mInfo.Duration; info.VideoBitrate = string.IsNullOrEmpty(mInfo.VideoBitrate) ? "" : mInfo.VideoBitrate; info.VideoBitDepth = string.IsNullOrEmpty(mInfo.VideoBitDepth) ? "" : mInfo.VideoBitDepth; info.VideoCodec = string.IsNullOrEmpty(mInfo.VideoCodec) ? "" : mInfo.VideoCodec; info.VideoFrameRate = string.IsNullOrEmpty(mInfo.VideoFrameRate) ? "" : mInfo.VideoFrameRate; info.VideoResolution = string.IsNullOrEmpty(mInfo.VideoResolution) ? "" : mInfo.VideoResolution; info.FullInfo = string.IsNullOrEmpty(mInfo.FullInfo) ? "" : mInfo.FullInfo; repo.Save(info); m = XmlDeserializeFromString <Media>(info.FullInfo); } } l.Medias = new List <Media>(); if (m != null) { m.Id = null; List <JMMContracts.KodiContracts.Stream> subs = SubtitleHelper.GetSubtitleStreamsKodi(v.FullServerPath); if (subs.Count > 0) { foreach (JMMContracts.KodiContracts.Stream s in subs) { s.Key = ServerUrl(int.Parse(ServerSettings.JMMServerFilePort), "file/0/" + Base64EncodeUrl(s.File), KodiObject.IsExternalRequest); } m.Parts[0].Streams.AddRange(subs); } foreach (Part p in m.Parts) { p.Id = null; p.File = v.FullServerPath; string ff = Path.GetExtension(v.FullServerPath); p.Key = ServerUrl(int.Parse(ServerSettings.JMMServerFilePort), "videolocal/0/" + v.VideoLocalID + "/file" + ff, KodiObject.IsExternalRequest); p.Accessible = "1"; p.Exists = "1"; bool vid = false; bool aud = false; bool txt = false; foreach (JMMContracts.KodiContracts.Stream ss in p.Streams.ToArray()) { if ((ss.StreamType == "1") && (!vid)) { vid = true; } if ((ss.StreamType == "2") && (!aud)) { aud = true; ss.Selected = "1"; } if ((ss.StreamType == "3") && (!txt)) { txt = true; ss.Selected = "1"; } } } l.Medias.Add(m); l.Duration = m.Duration; } }
public static string ContructVideoLocalIdUrl(int userid, int vid, JMMType type) { return(ServerUrl(int.Parse(ServerSettings.JMMServerPort), MainWindow.PathAddressPlex + "/GetMetadata/" + userid + "/" + (int)type + "/" + vid)); }
public static Video MayReplaceVideo(Video v1, AnimeSeries ser, Contract_AnimeSeries cserie, AniDB_Anime anime, JMMType type, int userid, bool all = true) { int epcount = all ? ser.GetAnimeEpisodesCountWithVideoLocal() : ser.GetAnimeEpisodesNormalCountWithVideoLocal(); if ((epcount == 1) && (anime.AnimeTypeEnum == enAnimeType.OVA || anime.AnimeTypeEnum == enAnimeType.Movie)) { List <AnimeEpisode> episodes = ser.GetAnimeEpisodes(); List <VideoLocal> l = episodes[0].GetVideoLocals(); if (l.Count > 0) { Video v2 = new Video(); try { if (PopulateVideo(v2, l[0], episodes[0], ser, cserie, anime, v1, JMMType.File, userid)) { v2.Thumb = anime.GetDefaultPosterDetailsNoBlanks().GenPoster(); return(v2); } } catch (Exception e) { //Fast fix if file do not exist, and still is in db. (Xml Serialization of video info will fail on null) } } } return(v1); }
private static void PopulateVideoEpisodeFromVideoLocal(Video l, VideoLocal v, JMMType type, int userid) { l.Type = "episode"; l.Summary = "Episode Overview Not Available"; //TODO Intenationalization l.Title = Path.GetFileNameWithoutExtension(v.FilePath); l.Key = ContructVideoLocalIdUrl(userid, v.VideoLocalID, type); l.AddedAt = v.DateTimeCreated.ToUnixTime(); l.UpdatedAt = v.DateTimeUpdated.ToUnixTime(); l.OriginallyAvailableAt = v.DateTimeCreated.ToPlexDate(); l.Year = v.DateTimeCreated.Year.ToString(); VideoInfo info = v.VideoInfo; Media m = null; if (info != null) { if (!string.IsNullOrEmpty(info.FullInfo)) { try { m = XmlDeserializeFromString <Media>(info.FullInfo); } catch (Exception) { info.FullInfo = null; } } if (string.IsNullOrEmpty(info.FullInfo)) { VideoInfoRepository repo = new VideoInfoRepository(); MediaInfoResult mInfo = FileHashHelper.GetMediaInfo(v.FullServerPath, true); info.AudioBitrate = string.IsNullOrEmpty(mInfo.AudioBitrate) ? "" : mInfo.AudioBitrate; info.AudioCodec = string.IsNullOrEmpty(mInfo.AudioCodec) ? "" : mInfo.AudioCodec; info.Duration = mInfo.Duration; info.VideoBitrate = string.IsNullOrEmpty(mInfo.VideoBitrate) ? "" : mInfo.VideoBitrate; info.VideoBitDepth = string.IsNullOrEmpty(mInfo.VideoBitDepth) ? "" : mInfo.VideoBitDepth; info.VideoCodec = string.IsNullOrEmpty(mInfo.VideoCodec) ? "" : mInfo.VideoCodec; info.VideoFrameRate = string.IsNullOrEmpty(mInfo.VideoFrameRate) ? "" : mInfo.VideoFrameRate; info.VideoResolution = string.IsNullOrEmpty(mInfo.VideoResolution) ? "" : mInfo.VideoResolution; info.FullInfo = string.IsNullOrEmpty(mInfo.FullInfo) ? "" : mInfo.FullInfo; repo.Save(info); m = XmlDeserializeFromString <Media>(info.FullInfo); } } l.Medias = new List <Media>(); if (m != null) { m.Id = null; List <JMMContracts.PlexContracts.Stream> subs = SubtitleHelper.GetSubtitleStreams(v.FullServerPath); if (subs.Count > 0) { foreach (JMMContracts.PlexContracts.Stream s in subs) { s.Key = ConstructFileStream(userid, s.File); } m.Parts[0].Streams.AddRange(subs); } foreach (Part p in m.Parts) { p.Id = null; string ff = Path.GetExtension(v.FullServerPath); p.Key = ConstructVideoLocalStream(userid, v.VideoLocalID, ff); p.Accessible = "1"; p.Exists = "1"; bool vid = false; bool aud = false; bool txt = false; foreach (JMMContracts.PlexContracts.Stream ss in p.Streams.ToArray()) { if ((ss.StreamType == "1") && (!vid)) { vid = true; } if ((ss.StreamType == "2") && (!aud)) { aud = true; ss.Selected = "1"; } if ((ss.StreamType == "3") && (!txt)) { txt = true; ss.Selected = "1"; } } } l.Medias.Add(m); l.Duration = m.Duration; } }
public static string ContructVideoUrl(this IProvider prov, int userid, string vid, JMMType type) { if (API.APIv1_Legacy_Module.request.Url.ToString().Contains("/api/")) { return(Helper.ServerUrl(prov.ServicePort, prov.ServiceAddress + "/api/GetMetadata/" + (int)type + "/" + vid)); } else { return(Helper.ServerUrl(prov.ServicePort, prov.ServiceAddress + "/GetMetadata/" + userid + "/" + (int)type + "/" + vid)); } }