Example #1
0
        public RawFile(NancyContext ctx, SVR_VideoLocal vl, int level, int uid)
        {
            if (vl != null)
            {
                id = vl.VideoLocalID;

                crc32    = vl.CRC32;
                ed2khash = vl.ED2KHash;
                md5      = vl.MD5;
                sha1     = vl.SHA1;

                created  = vl.DateTimeCreated;
                updated  = vl.DateTimeUpdated;
                duration = vl.Duration;

                if (vl.ReleaseGroup != null)
                {
                    group_full  = vl.ReleaseGroup.GroupName;
                    group_short = vl.ReleaseGroup.GroupNameShort;
                    group_id    = vl.ReleaseGroup.AniDB_ReleaseGroupID;
                }

                size        = vl.FileSize;
                hash        = vl.Hash;
                hash_source = vl.HashSource;

                is_ignored = vl.IsIgnored;
                VideoLocal_User vl_user = vl.GetUserRecord(uid);
                if (vl_user != null)
                {
                    offset = vl_user.ResumePosition;
                }
                else
                {
                    offset = 0;
                }

                VideoLocal_Place place = vl.GetBestVideoLocalPlace();
                if (place != null)
                {
                    filename            = place.FilePath;
                    videolocal_place_id = place.VideoLocal_Place_ID;
                    import_folder_id    = place.ImportFolderID;
                }

                if (vl.EpisodeCrossRefs.Count == 0)
                {
                    recognized = false;
                }
                else
                {
                    recognized = true;
                }

                if (vl.Media != null && (level > 1 || level == 0))
                {
                    media = new MediaInfo();

                    url = APIHelper.ConstructVideoLocalStream(ctx, uid, vl.Media.Id, "file." + vl.Media.Container, false);

                    MediaInfo new_media = new MediaInfo();

                    new_media.AddGeneral(MediaInfo.General.format, vl.Media.Container);
                    new_media.AddGeneral(MediaInfo.General.duration, vl.Media.Duration);
                    new_media.AddGeneral(MediaInfo.General.id, vl.Media.Id);
                    new_media.AddGeneral(MediaInfo.General.overallbitrate, vl.Media.Bitrate);

                    if (vl.Media.Parts != null)
                    {
                        new_media.AddGeneral(MediaInfo.General.size, vl.Media.Parts[0].Size);

                        foreach (Shoko.Models.PlexAndKodi.Stream p in vl.Media.Parts[0].Streams)
                        {
                            switch (p.StreamType)
                            {
                            //video
                            case "1":
                                new_media.AddVideo(p);
                                break;

                            //audio
                            case "2":
                                new_media.AddAudio(p);
                                break;

                            //subtitle
                            case "3":
                                new_media.AddSubtitle(p);
                                break;

                            //menu
                            case "4":
                                Dictionary <string, string> mdict = new Dictionary <string, string>();
                                //TODO APIv2: menu object could be usefull for external players
                                new_media.AddMenu(mdict);
                                break;
                            }
                        }
                    }

                    media = new_media;
                }
            }
        }
Example #2
0
        public RawFile(Entities.VideoLocal vl, int level)
        {
            if (vl != null)
            {
                id = vl.VideoLocalID;

                crc32 = vl.CRC32;
                ed2khash = vl.ED2KHash;
                md5 = vl.MD5;
                sha1 = vl.SHA1;

                created = vl.DateTimeCreated;
                updated = vl.DateTimeUpdated;
                duration = vl.Duration;

                filename = vl.FileName;
                size = vl.FileSize;
                hash = vl.Hash;
                hash_source = vl.HashSource;

                is_ignored = vl.IsIgnored;

                if (vl.Media != null && ( level > 1 || level == 0))
                {
                    media = new MediaInfo();

                    // TODO APIV2: replace 1 with userid or rewrite file server
                    url = APIHelper.ConstructVideoLocalStream(1, vl.Media.Id, "file." + vl.Media.Container, false);

                    MediaInfo new_media = new MediaInfo();

                    new_media.AddGeneral(MediaInfo.General.format, vl.Media.Container);
                    new_media.AddGeneral(MediaInfo.General.duration, vl.Media.Duration);
                    new_media.AddGeneral(MediaInfo.General.id, vl.Media.Id);
                    new_media.AddGeneral(MediaInfo.General.overallbitrate, vl.Media.Bitrate);

                    if (vl.Media.Parts != null)
                    {
                        new_media.AddGeneral(MediaInfo.General.size, vl.Media.Parts[0].Size);

                        foreach (JMMContracts.PlexAndKodi.Stream p in vl.Media.Parts[0].Streams)
                        {
                            switch (p.StreamType)
                            {
                                //video
                                case "1":
                                    new_media.AddVideo(p);
                                    break;
                                //audio
                                case "2":
                                    new_media.AddAudio(p);
                                    break;
                                //subtitle
                                case "3":
                                    new_media.AddSubtitle(p);
                                    break;
                                //menu
                                case "4":
                                    Dictionary<string, string> mdict = new Dictionary<string, string>();
                                    //TODO APIv2: menu object could be usefull for external players
                                    new_media.AddMenu(mdict);
                                    break;
                            }
                        }
                    }

                    media = new_media;
                }
            }
        }
Example #3
0
        public RawFile(HttpContext ctx, SVR_VideoLocal vl, int level, int uid, AnimeEpisode e = null)
        {
            if (vl == null)
            {
                return;
            }

            id = vl.VideoLocalID;

            crc32    = vl.CRC32;
            ed2khash = vl.ED2KHash;
            md5      = vl.MD5;
            sha1     = vl.SHA1;

            created  = vl.DateTimeCreated;
            updated  = vl.DateTimeUpdated;
            duration = vl.Duration;

            var releaseGroup = vl.ReleaseGroup;

            if (releaseGroup != null)
            {
                group_full  = releaseGroup.GroupName;
                group_short = releaseGroup.GroupNameShort;
                group_id    = releaseGroup.AniDB_ReleaseGroupID;
            }

            size        = vl.FileSize;
            hash        = vl.Hash;
            hash_source = vl.HashSource;

            is_ignored = vl.IsIgnored;
            var vl_user = vl.GetUserRecord(uid);

            offset = vl_user?.ResumePosition ?? 0;

            var place = vl.GetBestVideoLocalPlace();

            if (place != null)
            {
                filename            = place.FilePath;
                server_path         = place.FullServerPath;
                videolocal_place_id = place.VideoLocal_Place_ID;
                import_folder_id    = place.ImportFolderID;
            }

            url = APIV2Helper.ConstructVideoLocalStream(ctx, uid, vl.VideoLocalID.ToString(),
                                                        "file" + Path.GetExtension(filename), false);

            recognized = e != null || vl.EpisodeCrossRefs.Count != 0;

            if (vl.Media == null || level < 0)
            {
                return;
            }

            MediaInfo new_media = new MediaInfo();

            new_media.AddGeneral(MediaInfo.General.format, vl.Media.Container);
            new_media.AddGeneral(MediaInfo.General.duration, vl.Media.Duration);
            new_media.AddGeneral(MediaInfo.General.id, vl.Media.Id);
            new_media.AddGeneral(MediaInfo.General.overallbitrate, vl.Media.Bitrate);

            if (vl.Media.Parts != null)
            {
                new_media.AddGeneral(MediaInfo.General.size, vl.Media.Parts[0].Size);

                foreach (Stream p in vl.Media.Parts[0].Streams)
                {
                    switch (p.StreamType)
                    {
                    //video
                    case 1:
                        new_media.AddVideo(p);
                        break;

                    //audio
                    case 2:
                        new_media.AddAudio(p);
                        break;

                    //subtitle
                    case 3:
                        new_media.AddSubtitle(p);
                        break;

                    //menu
                    case 4:
                        Dictionary <string, string> mdict = new Dictionary <string, string>();
                        //TODO APIv2: menu object could be usefull for external players
                        new_media.AddMenu(mdict);
                        break;
                    }
                }
            }

            media = new_media;
        }
Example #4
0
        public RawFile(Entities.VideoLocal vl, int level, int uid)
        {
            if (vl != null)
            {
                id = vl.VideoLocalID;

                crc32    = vl.CRC32;
                ed2khash = vl.ED2KHash;
                md5      = vl.MD5;
                sha1     = vl.SHA1;

                created  = vl.DateTimeCreated;
                updated  = vl.DateTimeUpdated;
                duration = vl.Duration;

                size        = vl.FileSize;
                hash        = vl.Hash;
                hash_source = vl.HashSource;

                is_ignored = vl.IsIgnored;

                if (vl.Places != null && vl.Places.Count >= 0)
                {
                    filename            = vl.Places[0].FilePath;
                    videolocal_place_id = vl.Places[0].VideoLocal_Place_ID;
                    import_folder_id    = vl.Places[0].ImportFolderID;
                }

                if (vl.EpisodeCrossRefs.Count == 0)
                {
                    recognized = false;
                }
                else
                {
                    recognized = true;
                }

                if (vl.Media != null && (level > 1 || level == 0))
                {
                    media = new MediaInfo();

                    url = APIHelper.ConstructVideoLocalStream(uid, vl.Media.Id, "file." + vl.Media.Container, false);

                    MediaInfo new_media = new MediaInfo();

                    new_media.AddGeneral(MediaInfo.General.format, vl.Media.Container);
                    new_media.AddGeneral(MediaInfo.General.duration, vl.Media.Duration);
                    new_media.AddGeneral(MediaInfo.General.id, vl.Media.Id);
                    new_media.AddGeneral(MediaInfo.General.overallbitrate, vl.Media.Bitrate);

                    if (vl.Media.Parts != null)
                    {
                        new_media.AddGeneral(MediaInfo.General.size, vl.Media.Parts[0].Size);

                        foreach (JMMContracts.PlexAndKodi.Stream p in vl.Media.Parts[0].Streams)
                        {
                            switch (p.StreamType)
                            {
                            //video
                            case "1":
                                new_media.AddVideo(p);
                                break;

                            //audio
                            case "2":
                                new_media.AddAudio(p);
                                break;

                            //subtitle
                            case "3":
                                new_media.AddSubtitle(p);
                                break;

                            //menu
                            case "4":
                                Dictionary <string, string> mdict = new Dictionary <string, string>();
                                //TODO APIv2: menu object could be usefull for external players
                                new_media.AddMenu(mdict);
                                break;
                            }
                        }
                    }

                    media = new_media;
                }
            }
        }
        public RawFile(Entities.VideoLocal vl, int level, int uid)
        {
            if (vl != null)
            {
                id = vl.VideoLocalID;

                crc32 = vl.CRC32;
                ed2khash = vl.ED2KHash;
                md5 = vl.MD5;
                sha1 = vl.SHA1;

                created = vl.DateTimeCreated;
                updated = vl.DateTimeUpdated;
                duration = vl.Duration;

                size = vl.FileSize;
                hash = vl.Hash;
                hash_source = vl.HashSource;

                is_ignored = vl.IsIgnored;

                if (vl.Places != null && vl.Places.Count >= 0)
                {
                    filename = vl.Places[0].FilePath;
                    videolocal_place_id = vl.Places[0].VideoLocal_Place_ID;
                    import_folder_id = vl.Places[0].ImportFolderID;
                }

                if (vl.EpisodeCrossRefs.Count == 0)
                { recognized = false; }
                else
                { recognized = true; }

                if (vl.Media != null && ( level > 1 || level == 0))
                {
                    media = new MediaInfo();

                    url = APIHelper.ConstructVideoLocalStream(uid, vl.Media.Id, "file." + vl.Media.Container, false);

                    MediaInfo new_media = new MediaInfo();

                    new_media.AddGeneral(MediaInfo.General.format, vl.Media.Container);
                    new_media.AddGeneral(MediaInfo.General.duration, vl.Media.Duration);
                    new_media.AddGeneral(MediaInfo.General.id, vl.Media.Id);
                    new_media.AddGeneral(MediaInfo.General.overallbitrate, vl.Media.Bitrate);

                    if (vl.Media.Parts != null)
                    {
                        new_media.AddGeneral(MediaInfo.General.size, vl.Media.Parts[0].Size);

                        foreach (JMMContracts.PlexAndKodi.Stream p in vl.Media.Parts[0].Streams)
                        {
                            switch (p.StreamType)
                            {
                                //video
                                case "1":
                                    new_media.AddVideo(p);
                                    break;
                                //audio
                                case "2":
                                    new_media.AddAudio(p);
                                    break;
                                //subtitle
                                case "3":
                                    new_media.AddSubtitle(p);
                                    break;
                                //menu
                                case "4":
                                    Dictionary<string, string> mdict = new Dictionary<string, string>();
                                    //TODO APIv2: menu object could be usefull for external players
                                    new_media.AddMenu(mdict);
                                    break;
                            }
                        }
                    }

                    media = new_media;
                }
            }
        }