Get Embedded URL's Not in html Sourcecode
#16
i changed my code a little and got rid of empty space and all of a sudden it works. Very fussy this python

Anyway as you say too many links.
How would i go about writing code to do that. I know in my mind but dont know the coding.
I am looking at your code re DetermineHostUrl to get the host and id, but the website i am scraping shows a Megaupload link name wether is a megaupload.com link or the megavideo link and obviously megavideo work but megaupload dont

By the way just tried the megaupload test link in t0mm0's test addon and it fails

How do you handle it for a free account.

shall i push to git my changes for you to see
Reply
#17
Eldorado Wrote:I can see why you are doing it this way, I only mentioned it because you introduce to many extra clicks for the user

eg. User clicks on movie, then clicks on source, then has to click again to play movie

Why not make either the movie itself a video item or at the very least the sources? Then handle the scraping of the final video url within your 'if play:' block

Take a peak at my Project Free TV addon for an idea - https://github.com/Eldorados/eldorado-xbmc-addons

The Red Letter Media works in the same way as well

In my case I needed to know some extra info about what kind of video it was, so I created my own 'add_video_item' method that passed some extra parms, t0mmo is working on adding this into his common library

If I do a regex like this I can find the video id each time:
Code:
r = re.search('="http://[a-z/.&?_=:]+[/=](.+?)"',html)
print r.group(1)

You just then need to know what to do with it and where the id is from so that you can format a url to send into urlresolver - t0mmo is also working on a way of passing in just a host name and video id, no need to form a full url.. this way in your script you won't need to know or care what the source is

when selecting a link from an AddItem() and the video plays, what gets passed to the play section

I was thinking of something like, but need a small example.

Code:
if play:

    html = URLtoCheck(play) << not actual code. is it correct to check for play or would it still be url
    then regex the bits i want
    then pass correct url to below to run video..   This is the bit i dont know, how to run code and then automatically run the vid
    at present i just know how to make it run when clicking link.


    url = addon.queries.get('url', '')
    host = addon.queries.get('host', '')
    media_id = addon.queries.get('media_id', '')
    #stream_url = urlresolver.resolve(play)
    stream_url = urlresolver.HostedMediaFile(url=url, host=host, media_id=media_id).resolve()
    addon.resolve_url(stream_url)
Reply
#18
k_zeon Wrote:when selecting a link from an AddItem() and the video plays, what gets passed to the play section

I was thinking of something like, but need a small example.

Code:
if play:

    html = URLtoCheck(play) << not actual code. is it correct to check for play or would it still be url
    then regex the bits i want
    then pass correct url to below to run video..   This is the bit i dont know, how to run code and then automatically run the vid
    at present i just know how to make it run when clicking link.


    url = addon.queries.get('url', '')
    host = addon.queries.get('host', '')
    media_id = addon.queries.get('media_id', '')
    #stream_url = urlresolver.resolve(play)
    stream_url = urlresolver.HostedMediaFile(url=url, host=host, media_id=media_id).resolve()
    addon.resolve_url(stream_url)

Depends on how you want to display the source selection to the user

1. user clicks on movie and goes to next page with sources listed - eg. Icefilms
2. dialog box - user clicks on movie and dialog box pops up listing sources eg. t0mmo's or my addons

For user experience I prefer the dialog box, so to do this the movies are video items, add them using the add_video_item method and give them the url of the main page for the movie/tv show which lists the sources

That url gets passed in with the 'play' variable, so in your 'if play' block grab the url and scrape the page for your sources - the regex I gave you is hopefully good enough to grab video id's for any source link you have, using that you can pass it into urlresolver (the new branch)

Code:
if play:

html = get html(play)

#scrape page for host name and video id's

#display dialog box of sources

media_id = 'whatever user selected
host = 'whatever user selected

# i don't know exact syntax of the new url resolver stuff yet
stream_url = urlresolver.HostedMediaFile(host, media_id).resolve()
addon.resolve_url(stream_url)
Reply
#19
k_zeon Wrote:when selecting a link from an AddItem() and the video plays, what gets passed to the play section

I was thinking of something like, but need a small example.

Code:
if play:

    html = URLtoCheck(play) << not actual code. is it correct to check for play or would it still be url
    then regex the bits i want
    then pass correct url to below to run video..   This is the bit i dont know, how to run code and then automatically run the vid
    at present i just know how to make it run when clicking link.


    url = addon.queries.get('url', '')
    host = addon.queries.get('host', '')
    media_id = addon.queries.get('media_id', '')
    #stream_url = urlresolver.resolve(play)
    stream_url = urlresolver.HostedMediaFile(url=url, host=host, media_id=media_id).resolve()
    addon.resolve_url(stream_url)

both the test addon and letmewatchthis are updated in the videoid branch so feel free to use those as examples.

t0mm0
Reply
#20
t0mm0 , if a source is selected and the video has been pulled, is there anyway to check it is avail before playing or while trying to play.

ie
error = addon.resolve_url(stream_url)

if error = 1:
dialog....
else:
dialog..

thanks
Reply
#21
k_zeon Wrote:t0mm0 , if a source is selected and the video has been pulled, is there anyway to check it is avail before playing or while trying to play.

ie
error = addon.resolve_url(stream_url)

if error = 1:
dialog....
else:
dialog..

thanks

not sure what you mean. if the url cannot be resolved it already returns False (i might change that so that it returns an empty string rather than False which would neaten things up a bit)

t0mm0
Reply
#22
t0mm0 Wrote:not sure what you mean. if the url cannot be resolved it already returns False (i might change that so that it returns an empty string rather than False which would neaten things up a bit)

t0mm0

at the moment it pops up a dialog box to advise URL cannot be resolved but does not tell you why.

ie the link is still avail so tries to play , but video no longer exists.
Reply

Logout Mark Read Team Forum Stats Members Help
Get Embedded URL's Not in html Sourcecode0