XBMC Community Forum
script.module.urlresolver development - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Python Add-on Development (/forumdisplay.php?fid=26)
+--- Thread: script.module.urlresolver development (/showthread.php?tid=105707)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22


- DragonWin - 2011-08-29 06:55

k1m0s Wrote:First off I must say, Probably the best creation for making addons ever. Really appreciate your guys work. Makes thing easier on a meat head like me. I spet a cpl weeks trying to get megaup file to play with no luck at all till I tried this and it took just minutes. I have been messing with the test addon and was wondering if there is a way to add icons to the links in the format given

Thanks again for all the hard work fellas. Smile

Hey k1m0s

I think you can, give this a try
Code:
add_video_item(play, infolabels, img='', fanart='', resolved=False, total_items=0, playlist=False)

so I guess
Code:
addon.add_video_item('http://www.megavideo.com/?v=LYWNYM1J',
{'title': 'megavideo'}, 'special://MyPathToThumbnail')

Also have a look at this add_video_item

Hope it helps more than confuse Big Grin

@t0mm0
Thanks I'll give that a look when I get home from work.


- k1m0s - 2011-08-29 12:47

Thanks DragonWin, That worked perfect.. I kept trying , 'thumb': 'http://.....' and 'thumbnail' : But didnet need any of that. Thanks again man


- t0mm0 - 2011-08-29 15:52

k1m0s Wrote:First off I must say, Probably the best creation for making addons ever. Really appreciate your guys work. Makes thing easier on a meat head like me.

thanks k1m0s - please shout if you can think of anything that would make it easier!

t0mm0


- mynumbistongue - 2011-08-29 18:00

I dont know if this is possible but with megavideo having a 72 minute watch limit would there be a way to just stream those videos straight from megaupload to bypass the watch limit sorta like what this site does http://daiphyer.com/megavideo.com/download/link/generator ,just an idea to make life easier for the end user with no megavideo premium account.


- t0mm0 - 2011-08-29 18:39

mynumbistongue Wrote:I dont know if this is possible but with megavideo having a 72 minute watch limit would there be a way to just stream those videos straight from megaupload to bypass the watch limit sorta like what this site does http://daiphyer.com/megavideo.com/download/link/generator ,just an idea to make life easier for the end user with no megavideo premium account.

if the megavideo link uses 'd=XYZ1234' then it is easy, but i have no idea how to convert if it is the more usual 'v=XYZ1234' - does anyone know how it works?

on the other hand i have a feeling that the time limit may be implemented in the flash player and therefore not affect xbmc - does anyone know if this is the case (i've never tried to watch anything long with megavideo)?

even if that is the case it would be nice if it is possible to get the link to the original file on megaupload from any megavideo link....

t0mm0


- Eldorado - 2011-08-29 19:11

t0mm0 Wrote:without running the code but comparing it to rogerthis code, i think you want to use http_POST() instead of http_GET(). the 'header' variable you are creating is not actually headers but form data to POST.

urllib2 POSTs automatically when you pass it form data whereas my stuff expects you to explicitly choose GET or POST (i did that to try and make it clearer what the code does)

t0mm0

Cheers!

Is now resolving final url, though having some issues getting the link to play.. I'm thinking it could have to do with the time delay they impose on the site, also might be good to include a login process as the site states better speeds, shorter wait times on registered/premium users the same as MegaUpload

XBMC logs only show error - "error probing input format".. possibly because the link is no longer valid and is instead returning the html page

I'll get what I have into source for now, as the FLV portion works with no problems


- Eldorado - 2011-08-29 19:22

t0mm0 Wrote:check out the letmewatchthis addon which uses choose_source()

not sure what part of the addon you have got that code, but you seem to be doing addon.add_item() as well as urlresolver.choose_source()

you should have one part that adds video items (https://github.com/t0mm0/xbmc-urlresolver/blob/d82472e76bd9fb66dbdbd3079bf0b8866d9291a0/plugin.video.letmewatchthis/default.py#L177) - this will result in one entry in the xbmc list for each episode/video

then when you want to actually play a video you make the dictionary of hoster urls and titles for that one episode/video and pass it to urlresolver.choose_source() (https://github.com/t0mm0/xbmc-urlresolver/blob/d82472e76bd9fb66dbdbd3079bf0b8866d9291a0/plugin.video.letmewatchthis/default.py#L40)

hope that makes sense!

t0mm0

Since you guys are talking about this, thought I would chime in as well Smile

Is it possible for choose_source() to sort the list?

Also it could use some handling if a user doesn't select a source - currently it tries to play no matter what

And... add_video_item, currently I'm leaning towards a need to have more information passed when the user clicks on a video item.. such as a distinction between a tv show or a movie, so passing another tag other than just the 'play=' would be handy

Is it currently possible?


- t0mm0 - 2011-08-29 19:50

hi eldorado!

Eldorado Wrote:Cheers!

Is now resolving final url, though having some issues getting the link to play.. I'm thinking it could have to do with the time delay they impose on the site, also might be good to include a login process as the site states better speeds, shorter wait times on registered/premium users the same as MegaUpload

XBMC logs only show error - "error probing input format".. possibly because the link is no longer valid and is instead returning the html page

I'll get what I have into source for now, as the FLV portion works with no problems

you can reuse the countdown code that megaupload uses. it's not currently documented, but this is mainly as i think it is best moved out of urlresolver an into t0mm0.common.addon - for now look at the megaupload plugin for info.

Eldorado Wrote:Since you guys are talking about this, thought I would chime in as well Smile

Is it possible for choose_source() to sort the list?
anything is possible Wink
i guess sorting by resolver plugin priority order would be handy? or do you mean you want to specify an order (i can see that would be useful too)? i am still planning a setting to just try the highest priority link rather than pop up the list (falling through to the next one if the first doesn't work and so on)
Eldorado Wrote:Also it could use some handling if a user doesn't select a source - currently it tries to play no matter what
i think there is no way to tell if the selection is 'cancelled' (by pressing escape for example). maybe it should add a 'cancel' option in the list?
Eldorado Wrote:And... add_video_item, currently I'm leaning towards a need to have more information passed when the user clicks on a video item.. such as a distinction between a tv show or a movie, so passing another tag other than just the 'play=' would be handy

Is it currently possible?

yes i think so if you urlencode it into the url but it's not pretty. why would that sort of info be needed when you are playing? you should have already set up the listitem with all the infolabels and such by that point?

by the way i am back working on this again. today i've been experimenting with the ways to use hoster and video id rather than full url. not come up with anything i like better than my previous proposal yet though... whatever i try seems to add a lot of complication for not much gain in functionality.

t0mm0.


- Eldorado - 2011-08-29 21:38

t0mm0 Wrote:you can reuse the countdown code that megaupload uses. it's not currently documented, but this is mainly as i think it is best moved out of urlresolver an into t0mm0.common.addon - for now look at the megaupload plugin for info.

Yep, I have put in the countdown clock but still not able to play.. I'm going to pause on this guy for now to get more work done on my addon

When I check it into your repository I'll disable the AVI selection until myself or someone else can get to it

t0mm0 Wrote:anything is possible Wink
i guess sorting by resolver plugin priority order would be handy? or do you mean you want to specify an order (i can see that would be useful too)? i am still planning a setting to just try the highest priority link rather than pop up the list (falling through to the next one if the first doesn't work and so on)
i think there is no way to tell if the selection is 'cancelled' (by pressing escape for example). maybe it should add a 'cancel' option in the list?

Sorting.. now that you mention the priority idea, I think there could be many ways of sorting.. by priority, key or value.. etc.

Maybe just only do by priority and have it optional, leave it up to the developer to pre-sort the dict before passing it in?

For when a user cancels on the dialog box you can check the index value, -1 means nothing was selected

I have done this on my own addon but after 3-4 times I still get the 'failed to play items' msg box


t0mm0 Wrote:yes i think so if you urlencode it into the url but it's not pretty. why would that sort of info be needed when you are playing? you should have already set up the listitem with all the infolabels and such by that point?

by the way i am back working on this again. today i've been experimenting with the ways to use hoster and video id rather than full url. not come up with anything i like better than my previous proposal yet though... whatever i try seems to add a lot of complication for not much gain in functionality.

t0mm0.

This might be because I painted myself into a corner when doing my addon.. and using your letmewatchthis addon as a bit of a template Smile

If I can explain my situation correctly..

When I list movies I use the add_video_item method to add them, when a user clicks on the movie the 'play=' tag is passed and picked up in my script

Sudo code of what i do:

Code:
if play:

   -  Given the url parse all the links to sources from this page

   -  Display all sources in a dialog box

   -  User selects source, video url is resolved

   -  addon.resolve_url is called to play url

My issue is by using a catch all 'if play' block, I sometimes will be passing in a url where the sources need to be parsed out differently, such as movies have their sources laid out in one way while TV shows have theirs structured in another..

So in this design it would be nice to be able to optionally pass another tag that I could check and know how I need to parse the page

Obviously I could modify my design, but I'm a bit stuck on how to do so without writing in my own methods to add a video item.. or maybe making the movies a directory instead of a video item.. but presents a few more design changes, and I think will take away some functionality for metadata etc.

Ideas? Can maybe take this topic to my dev thread I started


- k1m0s - 2011-08-30 01:53

t0mm0 Wrote:thanks k1m0s - please shout if you can think of anything that would make it easier!

t0mm0

I would love to help but I do not have alot of time right now and am still pretty virgin to coding, enjoying learning what I can tho. Been studying your url resover files tho and am seeing things Ive never caught on to b4. Will be plugging around when I can tho. Thx again t0mm0


- DragonWin - 2011-08-30 18:23

Hey t0mm0,

I noticed that some novamov links don't work. They work fine in my browser but when I test them using the test addon no stream is available. I modified novamov to also return true on "embed.novamov.com/embed.php?width

I did a few tcpdumps and I noticed 3 differences.

  1. ip in key is not url encoded from xbmc
  2. xbmc does a HEAD to the stream url before doing a get
  3. On GET the browser adds a client=FLASH at the end


Here is "follow stream" from the tcpdumps, what really bugs me is the HEAD that is done from xbmc before the GET, where does that come from?

Note, I have anonymised some of the data like ip and OS level etc.

Browser
Get API: http://pastebin.com/Gx6DQs1N
Get Stream: http://pastebin.com/h3i8v1QU

xbmc
GET API: http://pastebin.com/YzG2Dsyr
HEAD: http://pastebin.com/exiA6f6J
Get Stream http://pastebin.com/KjYky8HG

[EDIT]
Forgot to include the url that does not work: http://embed.novamov.com/embed.php?width=600&height=480&v=eczrahg83yvi5&px=1
[/EDIT]


- t0mm0 - 2011-08-30 20:55

hi DragonWin

DragonWin Wrote:what really bugs me is the HEAD that is done from xbmc before the GET, where does that come from?

i'll take a look at the rest later, but i believe xbmc does a HEAD first to see if it can determine the mime type from that in order to choose the correct player.

t0mm0


- t0mm0 - 2011-09-01 01:14

just merged a load of cool stuff from DragonWin including
  • 3 new resolvers (divxstage, 2gbhosting, nolimitvideo)
  • addon.load_data() and addon.save_data() - easy way to save and load stuff (using pickle) in your addons profile dir
  • addon.show_small_popup() - pop up notification message

thanks DragonWin! (especially for also writing the docs for your new additionsWink)

i rebuilt the online docs too, so they include this stuff.

thanks,

t0mm0

ps. sorry but i'm too tired now so the novamov stuff will have to wait till tomorrow...


- DragonWin - 2011-09-01 06:42

t0mm0 Wrote:just merged a load of cool stuff from DragonWin including
  • 3 new resolvers (divxstage, 2gbhosting, nolimitvideo)
  • addon.load_data() and addon.save_data() - easy way to save and load stuff (using pickle) in your addons profile dir
  • addon.show_small_popup() - pop up notification message

thanks DragonWin! (especially for also writing the docs for your new additionsWink)

i rebuilt the online docs too, so they include this stuff.

thanks,

t0mm0


Your welcome, glad I could give some thing back with all the help I have received here Big Grin

I have started to look into context menu items, as the next step for favorites. I'm thinking it could work some thing like this (I have not decided yet, just got some individual parts to work last night.)

function to generate the context menu items via t0mm0.addon, this object would then be returned to the user.

MyContextObject = create_contextmenu(menuname, scriptargs, mode=True/False, [contextobject]):
Where menuname, is what is displayed to the user on right click, scriptargs is the arguments passed to the plugin, mode indicates if the function that is hit creates a new listitem with add_dir, add_item ect, contextmenuitem object is an existing object. The object is a previously returned contextmenu, and only used if the user wants to add more menu items for that individual list item to be added using add_item add_video_item add_music_item (eg. Go to favories, Add item as favorite)

As far as I could make out using XBMC.Container.Update() forces it to clear the itemlist, and accept a new itemlist to be displayed (eg. Go to favorite menu item), or XBMC.RunPlugin() is used for eg. "add to favorites" as that would not generate a new itemlist. Which is why we need to know from the addon what type it is, hence the True/False in the create_contextmenu()

add_item, add_video_item, add_music_item
would prob need 1 new arg, where it is the object returned from the create_contextmenu.

The end goal is to see if a functions like "add_favorite", "del_favorite", "show_favorites" can be created, so it's very easy to manage favorites. Of cause the end user also have the options to use the other functions, bypassing the favorite part entirely.

Thoughts?

t0mm0 Wrote:ps. sorry but i'm too tired now so the novamov stuff will have to wait till tomorrow...

No problem it was more of a heads up and just a quick peek to see if I could help out with a bit of debug information.


- DragonWin - 2011-09-01 07:12

Hi t0mm0

I just noticed that you change import pickle to cPickle. I omitted cPickle on purpose as there are some data type objects it can't handle (found it some where on the net can't remember what it is it can't handle) but pickle can.

Just thought I would mention it.