Пример #1
0
        public override List<string> getMultipleVideoUrls(VideoInfo video, bool inPlaylist = false)
        {
            List<String> videoUrls = new List<string>();
            System.Net.CookieContainer cookies = new System.Net.CookieContainer();

            String baseWebData = GetWebData(video.VideoUrl, cookies, null, null, true);
            int startIndex = baseWebData.IndexOf(MarkizaUtil.showVoyoParamsStart);
            if (startIndex >= 0)
            {
                int endIndex = baseWebData.IndexOf(MarkizaUtil.showVoyoParamsEnd, startIndex + MarkizaUtil.showVoyoParamsStart.Length);
                if (endIndex >= 0)
                {
                    baseWebData = baseWebData.Substring(startIndex, endIndex - startIndex);

                    String prod = String.Empty;
                    String unit = String.Empty;
                    String media = String.Empty;
                    String site = String.Empty;
                    String section = String.Empty;
                    String subsite = String.Empty;
                    String width = String.Empty;
                    String height = String.Empty;

                    Match match = Regex.Match(baseWebData, MarkizaUtil.showVoyoSiteParamRegex);
                    if (match.Success)
                    {
                        site = match.Groups["site"].Value;
                    }
                    match = Regex.Match(baseWebData, MarkizaUtil.showVoyoSectionParamRegex);
                    if (match.Success)
                    {
                        section = match.Groups["section"].Value;
                    }
                    match = Regex.Match(baseWebData, MarkizaUtil.showVoyoSubsiteParamRegex);
                    if (match.Success)
                    {
                        subsite = match.Groups["subsite"].Value;
                    }
                    match = Regex.Match(baseWebData, MarkizaUtil.showVoyoWidthParamRegex);
                    if (match.Success)
                    {
                        width = match.Groups["width"].Value;
                    }
                    match = Regex.Match(baseWebData, MarkizaUtil.showVoyoHeightParamRegex);
                    if (match.Success)
                    {
                        height = match.Groups["height"].Value;
                    }
                    match = Regex.Match(baseWebData, MarkizaUtil.showVoyoProdUnitMediaRegex);
                    if (match.Success)
                    {
                        prod = match.Groups["prod"].Value;
                        unit = match.Groups["unit"].Value;
                        media = match.Groups["media"].Value;
                    }

                    String cookiesRequestUrl = String.Format("http://voyo.markiza.sk/bin/usrtrck-new.php?section_id={0}&article_id=&gallery_id=&media_id=&article_date=&r={1}&c=", section, new Random().NextDouble());
                    GetWebData(cookiesRequestUrl, cookies, null, null, true);

                    cookiesRequestUrl = String.Format("http://voyo.markiza.sk/bin/eshop/ws/user.php?x=isLoggedIn&r={0}", new Random().NextDouble());
                    GetWebData(cookiesRequestUrl, cookies, null, null, true);

                    cookiesRequestUrl = String.Format("http://voyo.markiza.sk/bin/eshop/ws/user.php?x=login&r={0}", new Random().NextDouble());
                    GetWebDataFromPost(cookiesRequestUrl, String.Format("u={0}&p={1}", this.login, this.password), cookies, null, null, true);
                
                    String showParamsUrl = String.Format(MarkizaUtil.showVoyoVideoUrlFormat, prod, unit, media, site, section, subsite, site, width, height, new Random().NextDouble());
                    String showParamsData = GetWebData(showParamsUrl, cookies, null, null, true);

                    Newtonsoft.Json.Linq.JObject jObject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(showParamsData);
                    String decodedPage = (String)((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)jObject.First).Value);

                    String base64EncodedParameters = String.Empty;
                    String showVoyoUrlParamStart = String.Format(MarkizaUtil.showVoyoUrlParamStartFormat, media);
                    startIndex = decodedPage.IndexOf(showVoyoUrlParamStart);
                    if (startIndex >= 0)
                    {
                        endIndex = decodedPage.IndexOf(MarkizaUtil.showVoyoUrlParamEnd, startIndex + showVoyoUrlParamStart.Length);
                        if (endIndex >= 0)
                        {
                            base64EncodedParameters = decodedPage.Substring(startIndex + showVoyoUrlParamStart.Length, endIndex - startIndex - showVoyoUrlParamStart.Length);
                        }
                    }

                    if (!String.IsNullOrEmpty(base64EncodedParameters))
                    {
                        String decodedParams = HttpUtility.HtmlDecode(Flowplayer.Commercial.V3_1_5_17_002.Aes.Decrypt(base64EncodedParameters, Flowplayer.Commercial.V3_1_5_17_002.Aes.Key, Flowplayer.Commercial.V3_1_5_17_002.Aes.KeyType.Key128));

                        String host = String.Empty;
                        String fileName = String.Empty;
                        String connectionArgs = String.Empty;

                        match = Regex.Match(decodedParams, MarkizaUtil.showVoyoHostRegex);
                        if (match.Success)
                        {
                            jObject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject("{ \"host\": \"" + match.Groups["host"].Value + "\" }");
                            host = (String)((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)jObject.First).Value);
                        }
                        match = Regex.Match(decodedParams, MarkizaUtil.showVoyoFileNameRegex);
                        if (match.Success)
                        {
                            jObject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject("{ \"filename\": \"" + match.Groups["fileName"].Value + "\" }");
                            fileName = (String)((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)jObject.First).Value);
                        }

                        if (!(String.IsNullOrEmpty(host) || String.IsNullOrEmpty(fileName)))
                        {
                            String playPath = String.Format("mp4:{0}-1.mp4", fileName);

                            OnlineVideos.MPUrlSourceFilter.RtmpUrl rtmpUrl = new OnlineVideos.MPUrlSourceFilter.RtmpUrl(host) { TcUrl = host, PlayPath = playPath, App = "voyosk" };

                            match = Regex.Match(decodedParams, MarkizaUtil.showVoyoConnectionArgsRegex);
                            if (match.Success)
                            {
                                jObject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject("{ \"connectionArgs\":[" + match.Groups["connectionArgs"].Value + "] }");

                                Newtonsoft.Json.Linq.JArray jConnectionArray = jObject["connectionArgs"] as Newtonsoft.Json.Linq.JArray;
                                if ((jConnectionArray != null) && (jConnectionArray.Count > 0))
                                {
                                    MPUrlSourceFilter.RtmpObjectArbitraryData rtmpConnectionParams = new MPUrlSourceFilter.RtmpObjectArbitraryData();

                                    for (int i = 0; i < jConnectionArray.Count; i++)
                                    {
                                        var connectionItem = jConnectionArray[i];

                                        switch (connectionItem.Type)
                                        {
                                            case Newtonsoft.Json.Linq.JTokenType.None:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Object:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Array:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Constructor:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Property:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Comment:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Integer:
                                                rtmpConnectionParams.Objects.Add(new MPUrlSourceFilter.RtmpNumberArbitraryData(i.ToString(), (long)((Newtonsoft.Json.Linq.JValue)connectionItem).Value));
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Float:
                                                rtmpConnectionParams.Objects.Add(new MPUrlSourceFilter.RtmpNumberArbitraryData(i.ToString(), (float)((Newtonsoft.Json.Linq.JValue)connectionItem).Value));
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.String:
                                                rtmpConnectionParams.Objects.Add(new MPUrlSourceFilter.RtmpStringArbitraryData(i.ToString(), (String)((Newtonsoft.Json.Linq.JValue)connectionItem).Value));
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Boolean:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Null:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Undefined:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Date:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Raw:
                                                break;
                                            case Newtonsoft.Json.Linq.JTokenType.Bytes:
                                                break;
                                            default:
                                                break;
                                        }
                                    }
                                    
                                    rtmpUrl.ArbitraryData.Add(rtmpConnectionParams);
                                }
                            }

                            videoUrls.Add(rtmpUrl.ToString());
                        }
                    }
                }
            }

            return videoUrls;
        }
Пример #2
0
        public override List <string> getMultipleVideoUrls(VideoInfo video, bool inPlaylist = false)
        {
            List <String> videoUrls = new List <string>();

            System.Net.CookieContainer cookies = new System.Net.CookieContainer();

            String baseWebData = GetWebData(video.VideoUrl, cookies, null, null, true);
            int    startIndex  = baseWebData.IndexOf(MarkizaUtil.showVoyoParamsStart);

            if (startIndex >= 0)
            {
                int endIndex = baseWebData.IndexOf(MarkizaUtil.showVoyoParamsEnd, startIndex + MarkizaUtil.showVoyoParamsStart.Length);
                if (endIndex >= 0)
                {
                    baseWebData = baseWebData.Substring(startIndex, endIndex - startIndex);

                    String prod    = String.Empty;
                    String unit    = String.Empty;
                    String media   = String.Empty;
                    String site    = String.Empty;
                    String section = String.Empty;
                    String subsite = String.Empty;
                    String width   = String.Empty;
                    String height  = String.Empty;

                    Match match = Regex.Match(baseWebData, MarkizaUtil.showVoyoSiteParamRegex);
                    if (match.Success)
                    {
                        site = match.Groups["site"].Value;
                    }
                    match = Regex.Match(baseWebData, MarkizaUtil.showVoyoSectionParamRegex);
                    if (match.Success)
                    {
                        section = match.Groups["section"].Value;
                    }
                    match = Regex.Match(baseWebData, MarkizaUtil.showVoyoSubsiteParamRegex);
                    if (match.Success)
                    {
                        subsite = match.Groups["subsite"].Value;
                    }
                    match = Regex.Match(baseWebData, MarkizaUtil.showVoyoWidthParamRegex);
                    if (match.Success)
                    {
                        width = match.Groups["width"].Value;
                    }
                    match = Regex.Match(baseWebData, MarkizaUtil.showVoyoHeightParamRegex);
                    if (match.Success)
                    {
                        height = match.Groups["height"].Value;
                    }
                    match = Regex.Match(baseWebData, MarkizaUtil.showVoyoProdUnitMediaRegex);
                    if (match.Success)
                    {
                        prod  = match.Groups["prod"].Value;
                        unit  = match.Groups["unit"].Value;
                        media = match.Groups["media"].Value;
                    }

                    String cookiesRequestUrl = String.Format("http://voyo.markiza.sk/bin/usrtrck-new.php?section_id={0}&article_id=&gallery_id=&media_id=&article_date=&r={1}&c=", section, new Random().NextDouble());
                    GetWebData(cookiesRequestUrl, cookies, null, null, true);

                    cookiesRequestUrl = String.Format("http://voyo.markiza.sk/bin/eshop/ws/user.php?x=isLoggedIn&r={0}", new Random().NextDouble());
                    GetWebData(cookiesRequestUrl, cookies, null, null, true);

                    cookiesRequestUrl = String.Format("http://voyo.markiza.sk/bin/eshop/ws/user.php?x=login&r={0}", new Random().NextDouble());
                    GetWebDataFromPost(cookiesRequestUrl, String.Format("u={0}&p={1}", this.login, this.password), cookies, null, null, true);

                    String showParamsUrl  = String.Format(MarkizaUtil.showVoyoVideoUrlFormat, prod, unit, media, site, section, subsite, site, width, height, new Random().NextDouble());
                    String showParamsData = GetWebData(showParamsUrl, cookies, null, null, true);

                    Newtonsoft.Json.Linq.JObject jObject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(showParamsData);
                    String decodedPage = (String)((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)jObject.First).Value);

                    String base64EncodedParameters = String.Empty;
                    String showVoyoUrlParamStart   = String.Format(MarkizaUtil.showVoyoUrlParamStartFormat, media);
                    startIndex = decodedPage.IndexOf(showVoyoUrlParamStart);
                    if (startIndex >= 0)
                    {
                        endIndex = decodedPage.IndexOf(MarkizaUtil.showVoyoUrlParamEnd, startIndex + showVoyoUrlParamStart.Length);
                        if (endIndex >= 0)
                        {
                            base64EncodedParameters = decodedPage.Substring(startIndex + showVoyoUrlParamStart.Length, endIndex - startIndex - showVoyoUrlParamStart.Length);
                        }
                    }

                    if (!String.IsNullOrEmpty(base64EncodedParameters))
                    {
                        String decodedParams = HttpUtility.HtmlDecode(Flowplayer.Commercial.V3_1_5_17_002.Aes.Decrypt(base64EncodedParameters, Flowplayer.Commercial.V3_1_5_17_002.Aes.Key, Flowplayer.Commercial.V3_1_5_17_002.Aes.KeyType.Key128));

                        String host           = String.Empty;
                        String fileName       = String.Empty;
                        String connectionArgs = String.Empty;

                        match = Regex.Match(decodedParams, MarkizaUtil.showVoyoHostRegex);
                        if (match.Success)
                        {
                            jObject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject("{ \"host\": \"" + match.Groups["host"].Value + "\" }");
                            host    = (String)((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)jObject.First).Value);
                        }
                        match = Regex.Match(decodedParams, MarkizaUtil.showVoyoFileNameRegex);
                        if (match.Success)
                        {
                            jObject  = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject("{ \"filename\": \"" + match.Groups["fileName"].Value + "\" }");
                            fileName = (String)((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)jObject.First).Value);
                        }

                        if (!(String.IsNullOrEmpty(host) || String.IsNullOrEmpty(fileName)))
                        {
                            String playPath = String.Format("mp4:{0}-1.mp4", fileName);

                            OnlineVideos.MPUrlSourceFilter.RtmpUrl rtmpUrl = new OnlineVideos.MPUrlSourceFilter.RtmpUrl(host)
                            {
                                TcUrl = host, PlayPath = playPath, App = "voyosk"
                            };

                            match = Regex.Match(decodedParams, MarkizaUtil.showVoyoConnectionArgsRegex);
                            if (match.Success)
                            {
                                jObject = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject("{ \"connectionArgs\":[" + match.Groups["connectionArgs"].Value + "] }");

                                Newtonsoft.Json.Linq.JArray jConnectionArray = jObject["connectionArgs"] as Newtonsoft.Json.Linq.JArray;
                                if ((jConnectionArray != null) && (jConnectionArray.Count > 0))
                                {
                                    MPUrlSourceFilter.RtmpObjectArbitraryData rtmpConnectionParams = new MPUrlSourceFilter.RtmpObjectArbitraryData();

                                    for (int i = 0; i < jConnectionArray.Count; i++)
                                    {
                                        var connectionItem = jConnectionArray[i];

                                        switch (connectionItem.Type)
                                        {
                                        case Newtonsoft.Json.Linq.JTokenType.None:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Object:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Array:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Constructor:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Property:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Comment:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Integer:
                                            rtmpConnectionParams.Objects.Add(new MPUrlSourceFilter.RtmpNumberArbitraryData(i.ToString(), (long)((Newtonsoft.Json.Linq.JValue)connectionItem).Value));
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Float:
                                            rtmpConnectionParams.Objects.Add(new MPUrlSourceFilter.RtmpNumberArbitraryData(i.ToString(), (float)((Newtonsoft.Json.Linq.JValue)connectionItem).Value));
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.String:
                                            rtmpConnectionParams.Objects.Add(new MPUrlSourceFilter.RtmpStringArbitraryData(i.ToString(), (String)((Newtonsoft.Json.Linq.JValue)connectionItem).Value));
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Boolean:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Null:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Undefined:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Date:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Raw:
                                            break;

                                        case Newtonsoft.Json.Linq.JTokenType.Bytes:
                                            break;

                                        default:
                                            break;
                                        }
                                    }

                                    rtmpUrl.ArbitraryData.Add(rtmpConnectionParams);
                                }
                            }

                            videoUrls.Add(rtmpUrl.ToString());
                        }
                    }
                }
            }

            return(videoUrls);
        }