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


C# VideoInfo.GetOtherAsString方法代码示例

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


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

示例1: AddFavoriteVideo

        public bool AddFavoriteVideo(VideoInfo foVideo, string titleFromUtil, string siteName)
        {
			DatabaseUtility.RemoveInvalidChars(ref siteName);
            string title = string.IsNullOrEmpty(titleFromUtil) ? "" : DatabaseUtility.RemoveInvalidChars(titleFromUtil);
            string desc = string.IsNullOrEmpty(foVideo.Description) ? "" : DatabaseUtility.RemoveInvalidChars(foVideo.Description);
            string thumb = string.IsNullOrEmpty(foVideo.Thumb) ? "" : DatabaseUtility.RemoveInvalidChars(foVideo.Thumb);
            string url = string.IsNullOrEmpty(foVideo.VideoUrl) ? "" : DatabaseUtility.RemoveInvalidChars(foVideo.VideoUrl);
            string length = string.IsNullOrEmpty(foVideo.Length) ? "" : DatabaseUtility.RemoveInvalidChars(foVideo.Length);
            string airdate = string.IsNullOrEmpty(foVideo.Airdate) ? "" : DatabaseUtility.RemoveInvalidChars(foVideo.Airdate);
            string other = DatabaseUtility.RemoveInvalidChars(foVideo.GetOtherAsString());

            Log.Instance.Info("inserting favorite on site '{4}' with title: '{0}', desc: '{1}', thumb: '{2}', url: '{3}'", title, desc, thumb, url, siteName);

            //check if the video is already in the favorite list
            string lsSQL = string.Format("select VDO_ID from FAVORITE_VIDEOS where VDO_SITE_ID='{0}' AND VDO_URL='{1}' and VDO_OTHER_NFO='{2}'", siteName, url, other);
            if (m_db.Execute(lsSQL).Rows.Count > 0)
            {
                Log.Instance.Info("Favorite Video '{0}' already in database", title);
                return false;
            }

            lsSQL =
                string.Format(
                    "insert into FAVORITE_VIDEOS(VDO_NM,VDO_URL,VDO_DESC,VDO_TAGS,VDO_LENGTH,VDO_OTHER_NFO,VDO_IMG_URL,VDO_SITE_ID)VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')",
                    title, url, desc, airdate, length, other, thumb, siteName);
            m_db.Execute(lsSQL);
            if (m_db.ChangedRows() > 0)
            {
                Log.Instance.Info("Favorite '{0}' inserted successfully into database", foVideo.Title);
                return true;
            }
            else
            {
                Log.Instance.Warn("Favorite '{0}' failed to insert into database", foVideo.Title);
                return false;
            }
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:37,代码来源:FavoritesDatabase.cs

示例2: GetVideoUrl

 public override string GetVideoUrl(VideoInfo video)
 {
     bool isArchive = video.GetOtherAsString() == cArchiveCategory;
     string archiveUrl = "";
     if (isArchive)
     {
         Regex archiveRgx = new Regex(@".*(?<prefix>\d-)(?<id>\d*)");
         Match archiveMatch = archiveRgx.Match(video.VideoUrl);
         if (archiveMatch.Success)
         {
             Regex mediakantaIdRegex = new Regex(@"""mediakantaId"":""(?<id>[^""]*)");
             string id = archiveMatch.Groups["id"].Value;
             Match mediakantaIdMatch = mediakantaIdRegex.Match(GetWebData(string.Format(cUrlArchiveEmbedFormat, id, id)));
             if (mediakantaIdMatch.Success)
             {
                 archiveUrl = archiveMatch.Groups["prefix"].Value + mediakantaIdMatch.Groups["id"].Value;
             }
         }
     }
     string url = string.Format(cUrlHdsFormat, isArchive ? archiveUrl : video.VideoUrl);
     JObject json = GetWebData<JObject>(url, cache: false);
     JToken hdsStream = json["data"]["media"]["HDS"].FirstOrDefault(h => h["subtitles"] != null && h["subtitles"].Count() > 0);
     if (hdsStream == null)
     {
         hdsStream = json["data"]["media"]["HDS"].First;
     }
     else
     {
         JToken subtitle = hdsStream["subtitles"].FirstOrDefault(s => s["lang"].Value<string>() == ApiLanguage);
         if (subtitle == null) subtitle = hdsStream["subtitles"].FirstOrDefault(s => s["lang"].Value<string>() == ApiOtherLanguage);
         if (subtitle != null && subtitle["uri"] != null) video.SubtitleUrl = subtitle["uri"].Value<string>();
     }
     string data = hdsStream["url"].Value<string>();
     byte[] bytes = Convert.FromBase64String(data);
     RijndaelManaged rijndael = new RijndaelManaged();
     byte[] iv = new byte[16];
     Array.Copy(bytes, iv, 16);
     rijndael.IV = iv;
     rijndael.Key = Encoding.ASCII.GetBytes("yjuap4n5ok9wzg43");
     rijndael.Mode = CipherMode.CFB;
     rijndael.Padding = PaddingMode.Zeros;
     ICryptoTransform decryptor = rijndael.CreateDecryptor(rijndael.Key, rijndael.IV);
     int padLen = 16 - bytes.Length % 16;
     byte[] newbytes = new byte[bytes.Length - 16 + padLen];
     Array.Copy(bytes, 16, newbytes, 0, bytes.Length - 16);
     Array.Clear(newbytes, newbytes.Length - padLen, padLen);
     string result = null;
     using (MemoryStream msDecrypt = new MemoryStream(newbytes))
     {
         using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
         {
             using (StreamReader srDecrypt = new StreamReader(csDecrypt))
             {
                 result = srDecrypt.ReadToEnd();
             }
         }
     }
     Regex r;
     if (video.GetOtherAsString() == cApiContentTypeTvLive)
         r = new Regex(@"(?<url>.*\.f4m)");
     else
         r = new Regex(@"(?<url>.*hmac=[a-z0-9]*)");
     Match m = r.Match(result);
     if (m.Success)
     {
         result = m.Groups["url"].Value;
     }
     if (video.GetOtherAsString() == cApiContentTypeTvLive)
     {
         result += "?g=" + HelperUtils.GetRandomChars(12) + "&hdcore=3.3.0&plugin=flowplayer-3.3.0.0";
         MPUrlSourceFilter.AfhsManifestUrl f4mUrl = new MPUrlSourceFilter.AfhsManifestUrl(result)
         {
             LiveStream = true
         };
         result = f4mUrl.ToString();
     }
     else
     {
         result += "&g=" + HelperUtils.GetRandomChars(12) + "&hdcore=3.3.0&plugin=flowplayer-3.3.0.0";
     }
     return result;
 }
开发者ID:JSurf,项目名称:mp-onlinevideos2,代码行数:82,代码来源:YleUtil.cs

示例3: ExecuteContextMenuEntry

 public override ContextMenuExecutionResult ExecuteContextMenuEntry(Category selectedCategory, VideoInfo selectedItem, ContextMenuEntry choice)
 {
     if (selectedItem != null && choice.DisplayText.Contains("watchlist"))
     {
         ContextMenuExecutionResult result = new ContextMenuExecutionResult();
         string other = selectedItem.GetOtherAsString();
         JObject json = (JObject)JsonConvert.DeserializeObject(other);
         bool isSaved = json["saved"].Value<bool>();
         string guid = json["guid"].Value<string>();
         bool success;
         if (isSaved)
         {
             success = UnsaveVideo(guid);
         }
         else
         {
             success = SaveVideo(guid);
         }
         result.RefreshCurrentItems = success;
         result.ExecutionResultMessage = (success ? "OK: " : "ERROR: ") + choice.DisplayText + " (" + selectedItem.Title + ")";
         return result;
     }
     return base.ExecuteContextMenuEntry(selectedCategory, selectedItem, choice);
 }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:24,代码来源:HboNordicWebUtil.cs

示例4: GetContextMenuEntries

 public override List<ContextMenuEntry> GetContextMenuEntries(Category selectedCategory, VideoInfo selectedItem)
 {
     List<ContextMenuEntry> entries = new List<ContextMenuEntry>();
     if (selectedItem != null)
     {
         ContextMenuEntry entry = new ContextMenuEntry();
         string other = selectedItem.GetOtherAsString();
         JObject json = (JObject)JsonConvert.DeserializeObject(other);
         bool isSaved = json["saved"].Value<bool>();
         entry.DisplayText = isSaved ? "Remove from watchlist" : "Add to watchlist";
         entries.Add(entry);
     }
     return entries;
 }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:14,代码来源:HboNordicWebUtil.cs

示例5: GetVideoUrl

 public override string GetVideoUrl(VideoInfo video)
 {
     string other = video.GetOtherAsString();
     JObject json = (JObject)JsonConvert.DeserializeObject(other);
     bool isSaved = json["saved"].Value<bool>();
     if (isSaved)
         if (!UnsaveVideo(json["guid"].Value<string>()))
             throw new OnlineVideosException("Could not play video. Please try agian");
     if (!SaveVideo(json["guid"].Value<string>()))
         throw new OnlineVideosException("Could not play video. Please try agian");
     return WatchlistUrl + "|" + (!isSaved).ToString();
 }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:12,代码来源:HboNordicWebUtil.cs

示例6: GetMultipleVideoUrls

        public override List<String> GetMultipleVideoUrls(VideoInfo video, bool inPlaylist = false)
        {
            JObject data = GetWebData<JObject>(video.GetOtherAsString());
            video.PlaybackOptions.Clear();
            JArray episodes = (JArray)data["episodes"];
            JToken episode = episodes.FirstOrDefault(e => e["id"].ToString() == video.VideoUrl);
            IEnumerable<JToken> hlsStreams = episode["streams"].Where(s => s["format"].Value<string>().ToLower() == "ipad" && !s["drmProtected"].Value<bool>());
            if (hlsStreams == null || hlsStreams.Count() == 0)
                hlsStreams = episode["streams"].Where(s => s["format"].Value<string>().ToLower() == "iphone" && !s["drmProtected"].Value<bool>());
            if (hlsStreams != null && hlsStreams.Count() > 0)
            {
                try
                {
                    string url = hlsStreams.First()["source"].Value<string>();
                    string m3u8 = GetWebData(url);
                    Regex rgx = new Regex(@"WIDTH=(?<bitrate>\d+)[^c]*(?<url>[^\.]*\.m3u8)");
                    foreach (Match m in rgx.Matches(m3u8))
                    {
                        video.PlaybackOptions.Add(m.Groups["bitrate"].Value.ToString(), Regex.Replace(url, @"([^/]*?.m3u8)", delegate(Match match)
                        {
                            return m.Groups["url"].Value;
                        }));
                    }
                    video.PlaybackOptions = video.PlaybackOptions.OrderByDescending(p => int.Parse(p.Key)).ToDictionary(kvp => ((int.Parse(kvp.Key) /1000) + " kbps (HLS)"), kvp => kvp.Value);
                }
                catch { }
            }
            IEnumerable<JToken> streams = episode["streams"].Where(s => s["format"].Value<string>().ToLower() == "flash" && !s["drmProtected"].Value<bool>());
            string streamBaseUrl = (string)episode["streamBaseUrl"];
            Dictionary<string, string> rtmpD = new Dictionary<string, string>();
            if (streamBaseUrl != null && streams != null && streams.Count() > 0)
            {
                foreach (JToken stream in streams)
                {
                    MPUrlSourceFilter.RtmpUrl url = new MPUrlSourceFilter.RtmpUrl(streamBaseUrl)
                    {
                        SwfUrl = swfPlayer,
                        SwfVerify = true,
                        PlayPath = (string)stream["source"]
                    };
                    rtmpD.Add(((int)stream["bitrate"] / 1000).ToString(), url.ToString());
                }
                rtmpD = rtmpD.OrderByDescending(p => int.Parse(p.Key)).ToDictionary(kvp => (kvp.Key + " kbps (RTMP)"), kvp => kvp.Value);
                video.PlaybackOptions = video.PlaybackOptions.Concat(rtmpD).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
                if (retrieveSubtitles && (bool)episode["hasSubtitle"])
                {
                    string subData = GetWebData(string.Format("{0}/subtitles/{1}", apiBaseUrl, episode["id"].ToString()));
                    JArray subtitleJson = (JArray)JsonConvert.DeserializeObject(subData);
                    video.SubtitleText = formatSubtitle(subtitleJson);

                }
            }
            string firsturl = video.PlaybackOptions.First().Value;
            if (inPlaylist)
                video.PlaybackOptions.Clear();
            return new List<string>() { firsturl };
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:57,代码来源:Kanal59PlayUtil.cs


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