Example #1
0
        public async void StartUrl(MetaDataArgs data)
        {
            var m3U8Url = await GetM3U8Url(data);

            OnGetM3u8Url?.Invoke(this, new M3u8Args {
                url = m3U8Url
            });
        }
Example #2
0
        private void _mataData_OnGetMetaData(object sender, MetaDataArgs e)
        {
            //print info
            ChannelIdLabel.Content     = "Channel Id: " + e.ChannelId;
            BroadCastIdLabel.Content   = "Broadcast Id: " + e.Id;
            ChannelNameLabel.Content   = "Channel Name: " + e.ChannelName;
            TitleLabel.Content         = "Title: " + e.Title;
            StatusLabel.Content        = "Status: " + e.Status;
            ArchiveStatusLabel.Content = "Archive Status: " + e.ArchiveStatus;
            ProgramInfo.Visibility     = Visibility.Visible;
            AppendLogln("DEBUG", "LsaPath: " + e.LsaPath);

            //getUrl
            _mataData.StartUrl(e);
        }
Example #3
0
        private Task <string> GetM3U8Url(MetaDataArgs data)
        {
            return(Task.Run(() =>
            {
                string url = null;
                if (data.Status == "LIVE")
                {
                    url = "https://lssapi.line-apps.com/v1/live/playInfo?contentId=" + data.LsaPath;
                }
                else if (data.Status == "FINISHED")
                {
                    url = "https://lssapi.line-apps.com/v1/vod/playInfo?contentId=" + data.LsaPath;
                }
                else
                {
                    _mw.AppendLogln("ERROR", "Undefined status: " + data.Status);
                    return null;
                }

                var wc = new WebClient();
                wc.Headers.Add("Accept: text/html,*/*");
                wc.Headers.Add("User-Agent: " + Ver.UA);
                wc.Headers.Add("Accept-Language: ja;q=0.8,zh-CN,zh;q=0.6,en;q=0.4");

                //download json
                string json;
                try
                {
                    json = wc.DownloadString(url);
                }
                catch (Exception e)
                {
                    _mw.AppendLogln("ERROR", "Failed to load m3u8 url: " + e.Message);
                    return null;
                }

                //parse json
                var obj = JObject.Parse(json);
                var m3U8Url = obj["playUrls"]["720"].ToString();

                return m3U8Url;
            }));
        }