mathsgrinds / IETVNOW

Plays 12 live Irish TV stations (RTE1, RTE2, TV3, TG4, 3e, be3, RTEjr, RTE1 +1, RTE NEWS NOW, Oireachtas TV, Dail, Seanad)
Apache License 2.0
6 stars 3 forks source link

Great Work! A request! #1

Closed rlaphoenix closed 8 years ago

rlaphoenix commented 8 years ago

Could you PLEASE add support for TV Guides? As in make a router() mode like:

def play_fav(channel):
    xbmc.log("playing fav now..................")
    for video in get_videos('Live Irish TV'):
        if video['name'] == channel:
            xbmc.log("Name: " + str(video['name']))
            xbmc.log("Url: " + str(video['video']))
            play_item = xbmcgui.ListItem(path=str(video['video']))
            xbmcplugin.setResolvedUrl(__handle__, True, listitem=play_item)
            xbmc.log("It should be playing...................")
        xbmc.log("Looping............................")

def router(paramstring):
    params = dict(parse_qsl(paramstring[1:]))
    if params:
        if params['action'] == 'listing':
            list_videos(params['category'])
        elif params['action'] == 'play':
            play_video(params['video'])
        elif params['action'] == 'upd':
            play_fav(params['channel'])
    else:
        list_categories()

(Note: Code above is just an example, I tried to make it work but it wouldn't work for some reason.)

Just please set something up like that so we can do something like: plugin://plugin.video.live.irish.tv/?action=upd&channel=UTV Which would generate a new token and play the stream so that we can use TV Guide applications nice and smooth.

Great work was looking for something to play Irish streams since Irish TV was dead. This deserves much more <3

Also plz remove the pointless "Category".

And RTE 1+2 never seem to work. (The official streams are DRM protected, But not aertv.ie's ones. I can only manage to get the stream url from using Fiddler to sniff the url: http://pastebin.com/raw/6wUV4V98 But the token NEEDS to be one tied to YOUR ip. So somehow try and find a way to get the token and replace it on that url base. (If you need the base urls for the other aertv channels let me know, I can sniff em)

Great work was looking for something to play Irish streams since Irish TV was dead. This deserves much more <3

mathsgrinds commented 8 years ago

I've cleaned up the code, rte is working right now, I would like to add in aertv, but don't you need a paid account to get the token???

rlaphoenix commented 8 years ago

No not at all, You simply need to find a way to get the stream from the HTML/Headers - You can signup for free and use Fiddler to find the base url + token.

mathsgrinds commented 8 years ago

But I think the website gives free users only 10 minutes per day (at least that's what they say) and oddly when I navigate away from the page and go back, the feed is lost. Can you get it for more than 10 minutes on the free account?

rlaphoenix commented 8 years ago

No that Time Remaining thing is like a HD Preview Before you buy thing I believe

rlaphoenix commented 8 years ago

Oh nvm your right, Its only 10 mins/day D: I do have a Plus account doe Cant exactly share it around or anything, But ill try find a way to get the tokens and get back to you.

mathsgrinds commented 8 years ago

Yeah, that's what I thought :) I think the current version of the addon is as good as it gets

Anyway, feel free to fork, fix and pull anything you like :)

rlaphoenix commented 8 years ago

http://i.imgur.com/p3bpSHS.png Managed to find that it pops up in "Network" tab on Chrome in Dev Tools, See the &mu=rtmp%3A%2F%2Fd-deg-mcdn.magnet.ie%3A1935%2Frtplive%2Frte-one-v1500.stream%3Fstreamtoken%3D{{{{{...........}}}}} bit? Thats the stream just HTML encoded. Is there any way to record it in python and grab the first link that pops up in console under "ping.gif" and then just use Regex to extract what we need?

rlaphoenix commented 8 years ago

Im telling you if you get this working your plugins gonna be a massive hit and will fully replace the official kodi repos Irish TV plugin

mathsgrinds commented 8 years ago

Hmmm, there is no chance that this token is anywhere on the login page or store in a cookie? I'm able to log in and grab information.

PS: I'm not seeing this network activity you speak of, I can get session id and user_token, but no streamtoken. But this might be because I'm not getting any streams :) lol

mathsgrinds commented 8 years ago

I've been looking into AerTV, I feel it would need it's own addon, but I'm finding it too hard to get the token after I log in with Python. I'm not sure if it can be done, I'm seeking someone else's opinion.

mathsgrinds commented 8 years ago

I'm very close, I can get the streamtoken but only if I know the user_token, any ideas?

mathsgrinds commented 8 years ago

The new version now uses AER TV.

mathsgrinds commented 8 years ago

Closing

rlaphoenix commented 8 years ago

Sorry for no reply! Had no internet for ages! Got it back but its only 5gb of data, So gotta be careful! Great that you got it working! Wont be able to test but if it works thats awesome!

rlaphoenix commented 8 years ago

Also, I see you use https://twitter.com/ljcrkbgxro to grab the Token and Time from, But may I ask how you are getting them in the first place just incase issues occur I could make a backup server (I myself have a VPS)

rlaphoenix commented 8 years ago

Oh! And I dont think those tokens even work - They HAVE to be generated on your own IP address or they wont work - I tested this myself.

mathsgrinds commented 8 years ago

I check and the worked at work :) but they expire sooo... so I need to generate them often but I think my IP address was blocked. gr :(

mathsgrinds commented 8 years ago

The token is generated when one signs up to AER TV

rlaphoenix commented 8 years ago

Can you send me the files you were using to generate the tokens? Ill hop it onto my VPS and ill start it to throw crap onto a twitter too.

mathsgrinds commented 8 years ago

Grand, now before you do, I added in a tv3() and three_e() function. What you may not know is that for some reason on some devices the links don't work for those stations, so I think it is important for people to have a stream choice for those two stations. Do you have selenium on your server?

rlaphoenix commented 8 years ago

I have no idea what you mean abou Selenium, All I know is that I have an VPS server, (I can make it windows, ubuntu, linux etc)

Is there no way to just make a setting for login and password and just use that with some python to generate the token themselves?

rlaphoenix commented 8 years ago

Also - Im not sure if its because of my Update or anything but AerTV channels still dont work.

mathsgrinds commented 8 years ago

It's AER TV blocking :( sadly the script requires a lot of other stuff too, it;s not just a pure python code. But I have an idea to generate more tokens

rlaphoenix commented 8 years ago

rtmp://d-deg-mcdn.magnet.ie:1935/rtplive/rte-one-v1500.stream?streamtoken={{{{{...........}}}}}

Thats the StreamLink that is in that API link. Maybe if we just skip the whole API bit and just add the code() bit to the end of this and simply return it, Then that should work right?

rlaphoenix commented 8 years ago

obviously we need to change the rte-one but after /rtplive/ to the "station"

rlaphoenix commented 8 years ago

It will work, As ive tested it with my own stream token before, But all we need to do, Is find out how to get a streamtoken using just kodi. Get the token whenever someone wants to play an aertv channel and get it themselves from there own account instead of a Twitter account because what if the twitter gets closed for spam, Or your Server stops working etc? There wont be a backup.

If we add streamtoken grabbing code directly to the plugin we will PERMANENTLY have AerTV streams :P

rlaphoenix commented 8 years ago

Your Twitter bot just posted a new stream token, I tested it on My IP and it didnt work D: This means we need to have it generated on demand on the plugin itself using the user's IP address. The StreamTokens seem to be IPLocked :/

rlaphoenix commented 8 years ago

Stream with your token: rtmp://d-deg-mcdn.magnet.ie:1935/rtplive/rte-one-v1500.stream?streamtoken=c98b5a7f225218b94d6d68ecce53580632856cf6de074e107aeedda5b33d7531_1473375970 but a stream link with a Token I got myself works fine :/

mathsgrinds commented 8 years ago

And how did you get the token though? This is the key, the only way I can get a token is to scape it full an actually firefox browser running. This is the tricky part.

mathsgrinds commented 8 years ago

That's what my script does, it opens firefox, runs it, logs in and gets the token. This can't be done in kodi, there is no firefox.

rlaphoenix commented 8 years ago

Well can you send me your script? How im getting the token is through actual network logs. It can be found in Chromes F12 network tab and also using Fiddler4

mathsgrinds commented 8 years ago

Does github have private message feature?

rlaphoenix commented 8 years ago

Nope, But if you have discord: Add my username: Shiny#2141

mathsgrinds commented 8 years ago

lol :) I don't, here I'll paste it here:

rlaphoenix commented 8 years ago

Just Right Click > Zip and drag and drop into the Text Box :P

mathsgrinds commented 8 years ago

code.txt

rlaphoenix commented 8 years ago

Oh I see, Hmm... Would any of these work: http://stackoverflow.com/questions/2910221/how-can-i-login-to-a-website-with-python

We need to find a way to do this xD

rlaphoenix commented 8 years ago

Or maybe this: http://forum.kodi.tv/showthread.php?tid=99082 This is tailored specifically to kodi so maybe it would work?

rlaphoenix commented 8 years ago

https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/anarchintosh-projects/gethtml.py

This seems very promising it says next to it "gethtml with cookies support"

rlaphoenix commented 8 years ago

https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/anarchintosh-projects/weblogin.py

This seems like it would work if we use it against the API, I fiddled with the API before for an unrelated use, Ill see if I can get the login_data for it.

mathsgrinds commented 8 years ago

Sure, however I've looked into this, it doesn't seem to work because I think it is some kind of java script that is setting the token or something, that, it's not stored in a cookie until some java thingey runs, maybe, I dunno

rlaphoenix commented 8 years ago

Hmm I see, Well atm im working on the login script - Im working with a friend on Discord to get it to work - We are setting up the Post Data and Success Keys

mathsgrinds commented 8 years ago

Fantastic! I hope you guys get it working :) the AerTV function that makes the stream token requires the user token which you get when you log in, that's what I can't get.

rlaphoenix commented 8 years ago

yh working on it :P

rlaphoenix commented 8 years ago

The API gives this: {"statusCode":200,"statusMessage":"OK","data":{"user_token":"e70971b38dddce13ddd769ce3865e8dab0619221aeafd98bef16a56b6289301e_1473379310"

:P Working on the login now, Its going VERY well.

mathsgrinds commented 8 years ago

Oohh exciting :)

rlaphoenix commented 8 years ago

Im not great with response parsing, Maybe you can help:

#do the login and get the response
response = opener.open(req)
source = response.read()
response.close()

#if login suceeded, save the user_token
if re.search('user_token',source,re.IGNORECASE):
    #Some kind of parsing here to get the user token?
mathsgrinds commented 8 years ago

could you paste an example of the source please

rlaphoenix commented 8 years ago

{"statusCode":200,"statusMessage":"OK","data":{"user_token":"e70971b38dddce13ddd769ce3865e8dab0619221aeafd98bef16a56b6289301e_1473379310","id":"58567","firstName":"{hidden}","lastName":"{hidden}","email":"{hidden}","isPremium":true,"channelDefault":"rte-one","packages":{"free":{"name":"Free Channel Pack","code":"WEB_STD","price":"0.00"},"plus":{"name":"Aertv Plus","code":"AERTV_PLUS","price":"5.99"}},"dialog":[],"upsell":{"title":"Upgrade","body":"Get more channels with Aertv Platinum, available with Magnet Broadband. Visit www.magnet.ie or call 1890 809 000","label":"Upgrade","link":"http:\/\/www.magnet.ie"},"clientInfo":{"ip":"{hidden}","userAgent":"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)","platform":"browser","platformVersion":"","country":"uk","connectionType":"cable"},"statusMessage":"fb"}}

mathsgrinds commented 8 years ago

It's ugly but will get things going:

for s in source.split(","): if "user_token" in s: token = s.replace('"data":{"user_token":"','').replace('"','') break

print token