t3knoid / MagyarPlexTV

PlexTV plugin that streams live Hungarian television streams
MIT License
0 stars 0 forks source link

Add support for channel M2 #2

Open t3knoid opened 7 years ago

t3knoid commented 7 years ago

Use the following URL:

https://player.mediaklikk.hu/playernew/player.php?video=mtv2live

This part of the returned html contains the URL to the m3u8 file: See the "playlist" list.

` var pl = jwplayer('player'); var _contentId = null;

pl.setup( {
"autostart": "true",
"width": "100%",
"aspectratio": "16:9",
"primary": "html5",
"advertising": {
    "client": "vast"
},
"cast": {},
"playlist": [
    {
        "file": "\/\/c201-node62-cdn.connectmedia.hu\/1101\/17613152ee246640b857525ea5628bc6\/5a5d5142\/index.m3u8?v=5i",
        "type": "hls"
    }
]

} );

`

t3knoid commented 6 years ago

Here's a preliminary script that scrapes the m3u index file and reading its content

` import requests from lxml import html

search_str = "\/index.m3u8" index_feed = 'https://player.mediaklikk.hu/playernew/player.php?video=mtv2live'

Read index feed

pageContent=requests.get( index_feed ) tree = html.fromstring(pageContent.content)

Get the script text containing the m3u8 index URL

script=tree.xpath( '/html/body/script[3]/text()')[0]

Split the script into a list of individual lines

lines = script.split('\n')

Get the line containing index.m3u8

found_line = [s for s in lines if (search_str in s)][0]

url_parts=found_line.split('"') m3u8_index = 'https:%s' % url_parts[3].replace('\', '')

Get the m3u8 file so that we an parse the actual m3u8 page

m3u8_index_pageContent=requests.get( m3u8_index ) if pageContent.status_code == 200: print '%s' % m3u8_index_pageContent.content`