当前位置: 首页>>代码示例>>C#>>正文


C# IProvider.GetPlexClient方法代码示例

本文整理汇总了C#中IProvider.GetPlexClient方法的典型用法代码示例。如果您正苦于以下问题:C# IProvider.GetPlexClient方法的具体用法?C# IProvider.GetPlexClient怎么用?C# IProvider.GetPlexClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProvider的用法示例。


在下文中一共展示了IProvider.GetPlexClient方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetStream

 public MediaContainer GetStream(IProvider prov)
 {
     if (MediaContainer.Childrens.Count > 0 && MediaContainer.Childrens[0].Type == "movie")
     {
         MediaContainer.ViewGroup = null;
         MediaContainer.ViewMode = null;
     }
     bool isandroid = false;
     bool isios = false;
     PlexDeviceInfo dinfo = prov.GetPlexClient();
     if (dinfo!=null)
     {
         if (dinfo.Client==PlexClient.Android)
             isandroid = true;
         else if (dinfo.Client==PlexClient.IOS)
             isios = true;
     }
     MediaContainer.Childrens.ForEach(a =>
     {
         a.Group = null;
         if (prov.AddEpisodeNumberToTitlesOnUnsupportedClients && (isios || isandroid) && a.Type == "episode")
             a.Title = a.EpisodeNumber + ". " + a.Title;
         if (isandroid)
             a.Type = null;
         if (prov.RemoveFileAttribute)
         {
             if (a.Medias != null)
             {
                 foreach (Media m in a.Medias)
                 {
                     if (m.Parts != null)
                     {
                         foreach (Part p in m.Parts)
                         {
                             if (p.Streams != null)
                             {
                                 foreach (Stream s in p.Streams)
                                     s.File = null;
                             }
                         }
                     }
                 }
             }
         };
     });
     return MediaContainer;
 }
开发者ID:japanesemediamanager,项目名称:jmmserver,代码行数:47,代码来源:BaseObject.cs

示例2: GetFromFile

        private MediaContainer GetFromFile(IProvider prov, int userid, string Id, BreadCrumbs info)
        {
            int id;
            if (!int.TryParse(Id, out id))
                return new MediaContainer() { ErrorString = "Invalid File Id" };
            VideoLocal vi = RepoFactory.VideoLocal.GetByID(id);
            BaseObject ret =
                new BaseObject(prov.NewMediaContainer(MediaContainerTypes.File,
                    Path.GetFileNameWithoutExtension(vi.FileName ?? ""),
                    true, false, info));
            Video v2 = Helper.VideoFromVideoLocal(prov, vi, userid);
            List<Video> dirs = new List<Video>();
            dirs.EppAdd(prov, v2, info, true);
            v2.Thumb = prov.ConstructSupportImageLink("plex_404.png");
            v2.ParentThumb = prov.ConstructSupportImageLink("plex_unsort.png");
            PlexDeviceInfo dinfo = prov.GetPlexClient();
            if (prov.ConstructFakeIosParent && dinfo != null && dinfo.Client == PlexClient.IOS)

                v2.GrandparentKey =
                    prov.Proxyfy(prov.ConstructFakeIosThumb(userid, v2.ParentThumb,
                        v2.Art ?? v2.ParentArt ?? v2.GrandparentArt));
            v2.ParentKey = null;
            if (prov.UseBreadCrumbs)
                v2.Key = prov.ShortUrl(ret.MediaContainer.Key);
            ret.MediaContainer.Childrens = dirs;
            return ret.GetStream(prov);
        }
开发者ID:japanesemediamanager,项目名称:jmmserver,代码行数:27,代码来源:CommonImplementation.cs

示例3: GetFromEpisode

        private MediaContainer GetFromEpisode(IProvider prov, int userid, string Id, BreadCrumbs info)
        {
            int id;
            if (!int.TryParse(Id, out id))
                return new MediaContainer() { ErrorString = "Invalid Episode Id" };
            BaseObject ret =
                new BaseObject(prov.NewMediaContainer(MediaContainerTypes.Episode, "Episode", true, true, info));
            using (var session = DatabaseFactory.SessionFactory.OpenSession())
            {
                List<Video> dirs = new List<Video>();
                ISessionWrapper sessionWrapper = session.Wrap();

                AnimeEpisode e = RepoFactory.AnimeEpisode.GetByID(id);
                if (e == null)
                    return new MediaContainer() { ErrorString = "Invalid Episode Id" };
                KeyValuePair<AnimeEpisode, Contract_AnimeEpisode> ep =
                    new KeyValuePair<AnimeEpisode, Contract_AnimeEpisode>(e,
                        e.GetUserContract(userid));
                if (ep.Value != null && ep.Value.LocalFileCount == 0)
                    return new MediaContainer() { ErrorString = "Episode do not have videolocals" };
                AniDB_Episode aep = ep.Key.AniDB_Episode;
                if (aep == null)
                    return new MediaContainer() { ErrorString = "Invalid Episode AniDB link not found" };
                AnimeSeries ser = RepoFactory.AnimeSeries.GetByID(ep.Key.AnimeSeriesID);
                if (ser == null)
                    return new MediaContainer() { ErrorString = "Invalid Serie" };
                AniDB_Anime anime = ser.GetAnime();
                Contract_AnimeSeries con = ser.GetUserContract(userid);
                if (con == null)
                    return new MediaContainer() { ErrorString = "Invalid Serie, Contract not found" };
                try
                {
                    Video v = Helper.VideoFromAnimeEpisode(prov, con.CrossRefAniDBTvDBV2, ep, userid);
                    if (v != null)
                    {
                        Video nv = ser.GetPlexContract(userid);
                        Helper.AddInformationFromMasterSeries(v, con, ser.GetPlexContract(userid), prov is KodiProvider);
                        if (v.Medias != null && v.Medias.Count > 0)
                        {
                            v.Type = "episode";
                            dirs.EppAdd(prov, v, info, true);
                            PlexDeviceInfo dinfo = prov.GetPlexClient();
                            if (prov.ConstructFakeIosParent && dinfo != null && dinfo.Client == PlexClient.IOS)
                                v.GrandparentKey =
                                    prov.Proxyfy(prov.ConstructFakeIosThumb(userid, v.ParentThumb,
                                        v.Art ?? v.ParentArt ?? v.GrandparentArt));
                            v.ParentKey = null;
                        }
                        if (prov.UseBreadCrumbs)
                            v.Key = prov.ShortUrl(ret.MediaContainer.Key);
                        ret.MediaContainer.Art = prov.ReplaceSchemeHost(nv.Art ?? nv.ParentArt ?? nv.GrandparentArt);
                    }
                    ret.MediaContainer.Childrens = dirs;
                    return ret.GetStream(prov);
                }
                catch (Exception ex)
                {
                    //Fast fix if file do not exist, and still is in db. (Xml Serialization of video info will fail on null)
                }
            }
            return new MediaContainer() { ErrorString = "Episode Not Found" };
        }
开发者ID:japanesemediamanager,项目名称:jmmserver,代码行数:62,代码来源:CommonImplementation.cs

示例4: GetFilters

        public MediaContainer GetFilters(IProvider prov, string uid)
        {
            int t = 0;
            int.TryParse(uid, out t);
            JMMUser user = t > 0 ? Helper.GetJMMUser(uid) : Helper.GetUser(uid);
            if (user == null)
                return new MediaContainer() { ErrorString = "User not found" };
            int userid = user.JMMUserID;

            BreadCrumbs info = prov.UseBreadCrumbs
                ? new BreadCrumbs { Key = prov.ConstructFiltersUrl(userid), Title = "Anime" }
                : null;
            BaseObject ret =
                new BaseObject(prov.NewMediaContainer(MediaContainerTypes.Show, "Anime", false, false, info));
            if (!ret.Init(prov))
                return new MediaContainer(); //Normal OPTION VERB
            List<Video> dirs = new List<Video>();
            try
            {
                using (var session = DatabaseFactory.SessionFactory.OpenSession())
                {
                    List<GroupFilter> allGfs = RepoFactory.GroupFilter.GetTopLevel().Where(a => a.InvisibleInClients == 0 &&
                    (
                        (a.GroupsIds.ContainsKey(userid) && a.GroupsIds[userid].Count > 0)
                        || (a.FilterType & (int)GroupFilterType.Directory) == (int)GroupFilterType.Directory)
                    ).ToList();

                    foreach (GroupFilter gg in allGfs)
                    {
                        Directory pp = Helper.DirectoryFromFilter(prov, gg, userid);
                        if (pp != null)
                            dirs.Add(prov, pp, info);
                    }
                    List<VideoLocal> vids = RepoFactory.VideoLocal.GetVideosWithoutEpisode();
                    if (vids.Count > 0)
                    {
                        Directory pp = new Directory() { Type = "show" };
                        pp.Key = prov.ShortUrl(prov.ConstructUnsortUrl(userid));
                        pp.Title = "Unsort";
                        pp.AnimeType = JMMContracts.PlexAndKodi.AnimeTypes.AnimeUnsort.ToString();
                        pp.Thumb = prov.ConstructSupportImageLink("plex_unsort.png");
                        pp.LeafCount = vids.Count.ToString();
                        pp.ViewedLeafCount = "0";
                        dirs.Add(prov, pp, info);
                    }
                    var playlists = RepoFactory.Playlist.GetAll();
                    if (playlists.Count > 0)
                    {
                        Directory pp = new Directory() { Type = "show" };
                        pp.Key = prov.ShortUrl(prov.ConstructPlaylistUrl(userid));
                        pp.Title = "Playlists";
                        pp.AnimeType = JMMContracts.PlexAndKodi.AnimeTypes.AnimePlaylist.ToString();
                        pp.Thumb = prov.ConstructSupportImageLink("plex_playlists.png");
                        pp.LeafCount = playlists.Count.ToString();
                        pp.ViewedLeafCount = "0";
                        dirs.Add(prov, pp, info);
                    }
                    dirs = dirs.OrderBy(a => a.Title).ToList();
                }
                ret.MediaContainer.RandomizeArt(prov, dirs);
                if (prov.AddPlexPrefsItem)
                {
                    Directory dir = new Directory();
                    dir.Prompt = "Search";
                    dir.Thumb = dir.Art = "/:/plugins/com.plexapp.plugins.myanime/resources/Search.png";
                    dir.Key = "/video/jmm/search";
                    dir.Title = "Search";
                    dir.Search = "1";
                    dirs.Add(dir);
                }
                if (prov.AddPlexSearchItem)
                {
                    Directory dir = new Directory();
                    dir.Thumb = dir.Art = "/:/plugins/com.plexapp.plugins.myanime/resources/Gear.png";
                    dir.Key = "/:/plugins/com.plexapp.plugins.myanime/prefs";
                    dir.Title = "Preferences";
                    dir.Settings = "1";
                    dirs.Add(dir);
                }
                ret.Childrens = dirs;
                PlexDeviceInfo dinfo = prov.GetPlexClient();
                if (dinfo!=null)
                    logger.Info(dinfo.ToString());
                return ret.GetStream(prov);
            }
            catch (Exception ex)
            {
                logger.Error( ex,ex.ToString());
                return new MediaContainer() { ErrorString = "System Error, see JMMServer logs for more information" };
            }
        }
开发者ID:japanesemediamanager,项目名称:jmmserver,代码行数:91,代码来源:CommonImplementation.cs

示例5: GetItemsFromSerie


//.........这里部分代码省略.........
                episodes = episodes.Where(a => a.Value == null || a.Value.LocalFileCount > 0)
                    .ToDictionary(a => a.Key, a => a.Value);
                if (eptype.HasValue)
                {
                    episodes = episodes.Where(a => a.Key.EpisodeTypeEnum == eptype.Value)
                        .ToDictionary(a => a.Key, a => a.Value);
                }
                else
                {
                    List<enEpisodeType> types = episodes.Keys.Select(a => a.EpisodeTypeEnum).Distinct().ToList();
                    if (types.Count > 1)
                    {
                        ret = new BaseObject(prov.NewMediaContainer(MediaContainerTypes.Show, "Types", false, true, info));
                        if (!ret.Init(prov))
                            return new MediaContainer();
                        ret.MediaContainer.Art = cseries.AniDBAnime?.AniDBAnime?.DefaultImageFanart.GenArt(prov);
                        ret.MediaContainer.LeafCount =
                            (cseries.WatchedEpisodeCount + cseries.UnwatchedEpisodeCount).ToString();
                        ret.MediaContainer.ViewedLeafCount = cseries.WatchedEpisodeCount.ToString();
                        List<PlexEpisodeType> eps = new List<PlexEpisodeType>();
                        foreach (enEpisodeType ee in types)
                        {
                            PlexEpisodeType k2 = new PlexEpisodeType();
                            PlexEpisodeType.EpisodeTypeTranslated(k2, ee,
                                (AnimeTypes) cseries.AniDBAnime.AniDBAnime.AnimeType,
                                episodes.Count(a => a.Key.EpisodeTypeEnum == ee));
                            eps.Add(k2);
                        }
                        List<Video> dirs = new List<Video>();
                        //bool converttoseason = true;

                        foreach (PlexEpisodeType ee in  eps.OrderBy(a=>a.Name))
                        {
                            Video v = new Directory();
                            v.Art = nv.Art;
                            v.Title = ee.Name;
                            v.AnimeType = "AnimeType";
                            v.LeafCount = ee.Count.ToString();
                            v.ChildCount = v.LeafCount;
                            v.ViewedLeafCount = "0";
                            v.Key = prov.ShortUrl(prov.ConstructSerieIdUrl(userid, ee.Type + "_" + ser.AnimeSeriesID));
                            v.Thumb = Helper.ConstructSupportImageLink(prov, ee.Image);
                            if ((ee.AnimeType == AnimeTypes.Movie) || (ee.AnimeType == AnimeTypes.OVA))
                            {
                                v = Helper.MayReplaceVideo(v, ser, cseries, userid, false, nv);
                            }
                            dirs.Add(prov, v, info, false, true);
                        }
                        ret.Childrens = dirs;
                        return ret.GetStream(prov);
                    }
                }
                ret =
                    new BaseObject(prov.NewMediaContainer(MediaContainerTypes.Episode, ser.GetSeriesName(), true,
                        true, info));
                if (!ret.Init(prov))
                    return new MediaContainer();
                ret.MediaContainer.Art = cseries.AniDBAnime?.AniDBAnime?.DefaultImageFanart.GenArt(prov);
                ret.MediaContainer.LeafCount =
                    (cseries.WatchedEpisodeCount + cseries.UnwatchedEpisodeCount).ToString();
                ret.MediaContainer.ViewedLeafCount = cseries.WatchedEpisodeCount.ToString();

                // Here we are collapsing to episodes

                List<Video> vids = new List<Video>();

                if ((eptype.HasValue) && (info!=null))
                    info.ParentKey = info.GrandParentKey;
                bool hasRoles = false;
                foreach (KeyValuePair<AnimeEpisode, Contract_AnimeEpisode> ep in episodes)
                {
                    try
                    {
                        Video v = Helper.VideoFromAnimeEpisode(prov, cseries.CrossRefAniDBTvDBV2, ep, userid);
                        if (v!=null && v.Medias != null && v.Medias.Count > 0)
                        {
                            if (nocast && !hasRoles) hasRoles = true;
                            Helper.AddInformationFromMasterSeries(v, cseries, nv, hasRoles);
                            v.Type = "episode";
                            vids.Add(prov, v, info);
                            v.GrandparentThumb = v.ParentThumb;
                            PlexDeviceInfo dinfo = prov.GetPlexClient();
                            if (prov.ConstructFakeIosParent && dinfo != null && dinfo.Client == PlexClient.IOS)
                                v.GrandparentKey =
                                    prov.Proxyfy(prov.ConstructFakeIosThumb(userid, v.ParentThumb,
                                        v.Art ?? v.ParentArt ?? v.GrandparentArt));
                            v.ParentKey = null;
                            if (!hasRoles) hasRoles = true;
                        }
                    }
                    catch (Exception e)
                    {
                        //Fast fix if file do not exist, and still is in db. (Xml Serialization of video info will fail on null)
                    }
                }
                ret.Childrens = vids.OrderBy(a => int.Parse(a.EpisodeNumber)).ToList();
                FilterExtras(prov,ret.Childrens);
                return ret.GetStream(prov);
            }
        }
开发者ID:japanesemediamanager,项目名称:jmmserver,代码行数:101,代码来源:CommonImplementation.cs

示例6: GetUnsort

        private MediaContainer GetUnsort(IProvider prov, int userid, BreadCrumbs info)
        {
            BaseObject ret =
                new BaseObject(prov.NewMediaContainer(MediaContainerTypes.Video, "Unsort", true, true, info));
            if (!ret.Init(prov))
                return new MediaContainer();
            List<Video> dirs = new List<Video>();
            List<VideoLocal> vids = RepoFactory.VideoLocal.GetVideosWithoutEpisode();
            foreach (VideoLocal v in vids.OrderByDescending(a => a.DateTimeCreated))
            {
                try
                {
                    Video m = Helper.VideoFromVideoLocal(prov, v, userid);
                    dirs.Add(prov, m, info);
                    m.Thumb = prov.ConstructSupportImageLink("plex_404.png");
                    m.ParentThumb = prov.ConstructSupportImageLink("plex_unsort.png");
                    m.ParentKey = null;
                    PlexDeviceInfo dinfo = prov.GetPlexClient();
                    if (prov.ConstructFakeIosParent && dinfo != null && dinfo.Client == PlexClient.IOS)

                        m.GrandparentKey =
                            prov.Proxyfy(prov.ConstructFakeIosThumb(userid, m.ParentThumb,
                                m.Art ?? m.ParentArt ?? m.GrandparentArt));
                }
                catch (Exception e)
                {
                    //Fast fix if file do not exist, and still is in db. (Xml Serialization of video info will fail on null)
                }
            }
            ret.Childrens = dirs;
            return ret.GetStream(prov);
        }
开发者ID:japanesemediamanager,项目名称:jmmserver,代码行数:32,代码来源:CommonImplementation.cs

示例7: GetItemsFromPlaylist

        private MediaContainer GetItemsFromPlaylist(IProvider prov, int userid, string id, BreadCrumbs info)
        {
            var PlaylistID = -1;
            int.TryParse(id, out PlaylistID);

            if (PlaylistID == 0)
            {
                using (var session = DatabaseFactory.SessionFactory.OpenSession())
                {
                    var ret = new BaseObject(prov.NewMediaContainer(MediaContainerTypes.Show, "Playlists", true, true, info));
                    if (!ret.Init(prov))
                        return new MediaContainer(); //Normal
                    var retPlaylists = new List<Video>();
                    var playlists = RepoFactory.Playlist.GetAll();
                    var sessionWrapper = session.Wrap();

                    foreach (var playlist in playlists)
                    {
                        var dir = new Directory();
                        dir.Key = prov.ShortUrl(prov.ConstructPlaylistIdUrl(userid, playlist.PlaylistID));
                        dir.Title = playlist.PlaylistName;
                        dir.Id = playlist.PlaylistID.ToString();
                        dir.AnimeType = JMMContracts.PlexAndKodi.AnimeTypes.AnimePlaylist.ToString();
                        var episodeID = -1;
                        if (int.TryParse(playlist.PlaylistItems.Split('|')[0].Split(';')[1], out episodeID))
                        {
                            var anime = RepoFactory.AnimeEpisode.GetByID(episodeID).GetAnimeSeries(sessionWrapper).GetAnime();
                            dir.Thumb = anime?.GetDefaultPosterDetailsNoBlanks(sessionWrapper)?.GenPoster(prov);
                            dir.Art = anime?.GetDefaultFanartDetailsNoBlanks(sessionWrapper)?.GenArt(prov);
                            dir.Banner = anime?.GetDefaultWideBannerDetailsNoBlanks(sessionWrapper)?.GenArt(prov);
                        }
                        else
                        {
                            dir.Thumb = prov.ConstructSupportImageLink("plex_404V.png");
                        }
                        dir.LeafCount = playlist.PlaylistItems.Split('|').Count().ToString();
                        dir.ViewedLeafCount = "0";
                        retPlaylists.Add(prov, dir, info);
                    }
                    retPlaylists = retPlaylists.OrderBy(a => a.Title).ToList();
                    ret.Childrens = retPlaylists;
                    return ret.GetStream(prov);
                }
            }
            if (PlaylistID > 0)
            {
                var playlist = RepoFactory.Playlist.GetByID(PlaylistID);
                var playlistItems = playlist.PlaylistItems.Split('|');
                var vids = new List<Video>();
                var ret =
                    new BaseObject(prov.NewMediaContainer(MediaContainerTypes.Episode, playlist.PlaylistName, true, true,
                        info));
                if (!ret.Init(prov))
                    return new MediaContainer(); //Normal
                foreach (var item in playlistItems)
                {
                    try
                    {
                        var episodeID = -1;
                        int.TryParse(item.Split(';')[1], out episodeID);
                        if (episodeID < 0) return new MediaContainer() { ErrorString = "Invalid Episode ID" };
                        AnimeEpisode e = RepoFactory.AnimeEpisode.GetByID(episodeID);
                        if (e == null)
                            return new MediaContainer() { ErrorString = "Invalid Episode" };
                        KeyValuePair<AnimeEpisode, Contract_AnimeEpisode> ep =
                            new KeyValuePair<AnimeEpisode, Contract_AnimeEpisode>(e,
                                e.GetUserContract(userid));
                        if (ep.Value != null && ep.Value.LocalFileCount == 0)
                            continue;
                        AnimeSeries ser = RepoFactory.AnimeSeries.GetByID(ep.Key.AnimeSeriesID);
                        if (ser == null)
                            return new MediaContainer() { ErrorString = "Invalid Series" };
                        Contract_AnimeSeries con = ser.GetUserContract(userid);
                        if (con == null)
                            return new MediaContainer() { ErrorString = "Invalid Series, Contract not found" };
                        Video v = Helper.VideoFromAnimeEpisode(prov, con.CrossRefAniDBTvDBV2, ep, userid);
                        if (v != null && v.Medias != null && v.Medias.Count > 0)
                        {
                            Helper.AddInformationFromMasterSeries(v, con, ser.GetPlexContract(userid));
                            v.Type = "episode";
                            vids.Add(prov, v, info);
                            PlexDeviceInfo dinfo = prov.GetPlexClient();
                            if (prov.ConstructFakeIosParent && dinfo!=null && dinfo.Client==PlexClient.IOS)
                                v.GrandparentKey =
                                    prov.Proxyfy(prov.ConstructFakeIosThumb(userid, v.ParentThumb,
                                        v.Art ?? v.ParentArt ?? v.GrandparentArt));
                            v.ParentKey = null;
                        }
                    }
                    catch (Exception e)
                    {
                        //Fast fix if file do not exist, and still is in db. (Xml Serialization of video info will fail on null)
                    }
                }
                ret.MediaContainer.RandomizeArt(prov, vids);
                ret.Childrens = vids;
                return ret.GetStream(prov);
            }
            return new MediaContainer() { ErrorString = "Invalid Playlist" };
        }
开发者ID:japanesemediamanager,项目名称:jmmserver,代码行数:100,代码来源:CommonImplementation.cs


注:本文中的IProvider.GetPlexClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。