示例#1
0
        public static XMLTorrentUpload GetXMLTorrentUpload(MediaInfo2 mi)
        {
            string format = string.Empty;
            string res = string.Empty;
            string media = mi.Source;

            if (mi.MediaTypeChoice == MediaType.MediaDisc)
            {
                format = mi.Source;
                res = mi.Overall.Video.Standard;
                if (format == "DVD-5" || format == "DVD-9")
                {
                    media = "DVD";
                }
            }
            else if (!string.IsNullOrEmpty(mi.Overall.Video.Codec))
            {
                string codec = mi.Overall.Video.Codec.ToLower();
                if (codec.Contains("divx"))
                {
                    format = "DivX";
                }
                else if (codec.Contains("xvid"))
                {
                    format = "XviD";
                }
                else if (codec.Contains("avc") || codec.Contains("x264"))
                {
                    format = "H.264";
                }
            }

            if (string.IsNullOrEmpty(res) && !string.IsNullOrEmpty(mi.Overall.Video.Height) && !string.IsNullOrEmpty(mi.Overall.Video.Width))
            {
                string height = mi.Overall.Video.Height;
                double dblWidth = 0.0;
                double dblHeight = 0.0;
                double.TryParse(mi.Overall.Video.Width, out dblWidth);
                double.TryParse(height, out dblHeight);

                if (dblWidth > 1900)
                {
                    res = "1080p";
                }
                else if (dblWidth > 1200)
                {
                    res = "720p";
                }
                else if (dblHeight > 480)
                {
                    res = "576p";
                }
                else if (dblWidth > 700)
                {
                    res = "480p";
                }
                else
                {
                    res = mi.Overall.Video.Resolution;
                }
            }

            string fileType = string.Empty;
            string ext = mi.Overall.FileExtension.ToLower();
            string[] exts = new string[] { "avi", "mpg", "mpeg", "mkv", "mp4", "vob", "iso" };
            if (!string.IsNullOrEmpty(ext))
            {
                foreach (string exMy in exts)
                {
                    if (ext.Contains(exMy))
                    {
                        fileType = exMy.ToUpper();
                        fileType = fileType.Replace("MPEG", "MPG");
                        fileType = fileType.Replace("VOB", "VOB IFO");
                        break;
                    }
                }
            }

            XMLTorrentUpload xmlUpload = new XMLTorrentUpload()
            {
                TorrentFilePath = mi.TorrentCreateInfoMy.TorrentFilePath,
                ReleaseDescription = mi.ReleaseDescription,
                MediaInfoSummary = mi.Overall.Summary,
                Format = format,
                Resolution = res,
                Width = mi.Overall.Video.Width,
                Height = mi.Overall.Video.Height,
                Media = media,
                FileType = fileType
            };

            if (mi.UploadScreenshots)
            {
                switch (mi.MediaTypeChoice)
                {
                    case MediaType.MediaDisc:
                        foreach (Screenshot ss in mi.Overall.Thumbnailer.Screenshots)
                        {
                            xmlUpload.Screenshots.Add(ss.FullImageLink);
                        }
                        break;

                    default:
                        foreach (MediaFile mf in mi.MediaFiles)
                        {
                            foreach (Screenshot ss in mf.Thumbnailer.Screenshots)
                            {
                                xmlUpload.Screenshots.Add(ss.FullImageLink);
                            }
                        }
                        break;
                }
            }

            return xmlUpload;
        }
示例#2
0
        public static XMLTorrentUpload GetXMLTorrentUpload(MediaInfo2 mi)
        {
            string format = string.Empty;
            string res    = string.Empty;
            string media  = mi.Source;

            if (mi.MediaTypeChoice == MediaType.MediaDisc)
            {
                format = mi.Source;
                res    = mi.Overall.Video.Standard;
                if (format == "DVD-5" || format == "DVD-9")
                {
                    media = "DVD";
                }
            }
            else if (!string.IsNullOrEmpty(mi.Overall.Video.Codec))
            {
                string codec = mi.Overall.Video.Codec.ToLower();
                if (codec.Contains("divx"))
                {
                    format = "DivX";
                }
                else if (codec.Contains("xvid"))
                {
                    format = "XviD";
                }
                else if (codec.Contains("avc") || codec.Contains("x264"))
                {
                    format = "H.264";
                }
            }

            if (string.IsNullOrEmpty(res) && !string.IsNullOrEmpty(mi.Overall.Video.Height) && !string.IsNullOrEmpty(mi.Overall.Video.Width))
            {
                string height    = mi.Overall.Video.Height;
                double dblWidth  = 0.0;
                double dblHeight = 0.0;
                double.TryParse(mi.Overall.Video.Width, out dblWidth);
                double.TryParse(height, out dblHeight);

                if (dblWidth > 1900)
                {
                    res = "1080p";
                }
                else if (dblWidth > 1200)
                {
                    res = "720p";
                }
                else if (dblHeight > 480)
                {
                    res = "576p";
                }
                else if (dblWidth > 700)
                {
                    res = "480p";
                }
                else
                {
                    res = mi.Overall.Video.Resolution;
                }
            }

            string fileType = string.Empty;
            string ext      = mi.Overall.FileExtension.ToLower();

            string[] exts = new string[] { "avi", "mpg", "mpeg", "mkv", "mp4", "vob", "iso" };
            if (!string.IsNullOrEmpty(ext))
            {
                foreach (string exMy in exts)
                {
                    if (ext.Contains(exMy))
                    {
                        fileType = exMy.ToUpper();
                        fileType = fileType.Replace("MPEG", "MPG");
                        fileType = fileType.Replace("VOB", "VOB IFO");
                        break;
                    }
                }
            }

            XMLTorrentUpload xmlUpload = new XMLTorrentUpload()
            {
                TorrentFilePath    = mi.TorrentCreateInfoMy.TorrentFilePath,
                ReleaseDescription = mi.ReleaseDescription,
                MediaInfoSummary   = mi.Overall.Summary,
                Format             = format,
                Resolution         = res,
                Width    = mi.Overall.Video.Width,
                Height   = mi.Overall.Video.Height,
                Media    = media,
                FileType = fileType
            };

            if (mi.UploadScreenshots)
            {
                switch (mi.MediaTypeChoice)
                {
                case MediaType.MediaDisc:
                    foreach (Screenshot ss in mi.Overall.Thumbnailer.Screenshots)
                    {
                        xmlUpload.Screenshots.Add(ss.FullImageLink);
                    }
                    break;

                default:
                    foreach (MediaFile mf in mi.MediaFiles)
                    {
                        foreach (Screenshot ss in mf.Thumbnailer.Screenshots)
                        {
                            xmlUpload.Screenshots.Add(ss.FullImageLink);
                        }
                    }
                    break;
                }
            }

            return(xmlUpload);
        }