Kodi Community Forum

Full Version: Modular video URL resolving addon?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hi all,
recently there have been a lot of video streaming plugins that all have to deal with resolving the streamable video URL individually. The most annoying things here are probably one-click-hosting services and youtube-like streaming websites that are a pain to program and debug. If we created one modular addon just for unifying these efforts, it would be much easier to create content plugins for websites distributing their media files using these services.

It should work something like in the youtube plugin:
Code:
url = "plugin://plugin.video.youtube/?path=/root/search&action=play_video&videoid=SOMEID"
, but support a variety of services along with user/premium accounts.

The services that are currently working in other plugins that I know of are: Hotfile, Rapidshare, Megaupload, Youtube, Filesonic. There are probably many more. What do you think?
Such an addon would be great Big Grin

+ addon development simplified a lot
+ bugfixes have only to be done in a single addon (APIs change...)
+ new features in this addon are immediately available in all addons relying on it
yes brilliant idea!
centralised url resolving....

i would be willing to work on this.
want to make a git development repo? edit: i have, see post #6

bear in mind it would need to support early login for some sites, and a few other weird features, so....

it would be much better to package it as a module, so you put in your addon.xml:

<import addon="script.module.videoresolver" version="0.0.1"/>

and in you python: import videoresolver

then you can call it in more pythonic ways from within your addon.

like how this works script.module.simplejson

bit of made up python example:
PHP Code:
import videoresolver
resolved_url 
videoresolver.youtube.resolve('url'flag1flag2)
print 
resolved_url 

could even add a function that detects what site url you are throwing at it, and automatically uses the correct resolver. (i've used a re.search on my urls in megaroutines to do this)



i started work on a megaupl*ad one that i want to expand to megavide*o and their adult equivalents.
https://github.com/icefilms-xbmc/megaroutines
isn't setResolvedUrl function doing that?
maybe u misunderstood, i meant that it could be used in conjunction with setResolvedURL
maybe its not good that i call it resolved_url Smile
i'll call it video_url to avoid confusion.

(really rough function example to show how it could be used in conjunction)
PHP Code:
import videoresolver,xbmcgui,xbmcplugin

def PLAY
(url):
    
    
video_url videoresolver.youtube.resolve(urlflag1flag2)

    
item xbmcgui.ListItem(path=video_url)
    return 
xbmcplugin.setResolvedUrl(pluginhandleTrueitem
update:
created git repo to host development, because i'm eager like that.

https://github.com/icefilms-xbmc/videour...ver-module

anyone who wants to dev it, message me with their github account name and i will add them as a repo owner.

i'm also adding to the README a list of links to certain addons that provide python code to resolve different video sites, that could be merged into the module.

havn't actually begun proper dev on it, but i've created a rough folder/file structure of how it will look.
Wow, that was fast. Let's see what we need.
I suggest the following methods:

individual host-specific modules:
- function to check if a URL is a valid link for that file host (or filter a list of URLs)
- function to check if valid URLs are still up (filter array of URLs)
- function to generate link for video streaming from a given URL of that file host
- function or regular expression to filter out links from an HTML page source
- function to check if login details are supplied and if they are valid
- function to check if login is premium/is sufficient for streaming content with XBMC
- function to login with these details if necessary

general link resolver module:
- function to find out what submodule this link belongs to (hotfile, megaup, etc.)
- function to parse an HTML page for links of any known filehost that allows for streaming (valid account), direct resolving of URLs as an optional flag
- function to parse an HTML page for links of a specific file host, direct resolving optional
- function to log in to all/one specific file host
- function to check which file hosts are available for streaming
- function to resolve a link or a list of links to streamable URLs

the methods to resolve or filter URLs should also have the ability to return file names as they are not always contained in the unresolves URLs.
This is not a complete list, just a few thoughts on how things might work. Please let me know what you think!
Unbehagen Wrote:individual host-specific modules:
- function to check if a URL is a valid link for that file host (or filter a list of URLs)
- function to check if valid URLs are still up (filter array of URLs)
- function to generate link for video streaming from a given URL of that file host
- function or regular expression to filter out links from an HTML page source
- function to check if login details are supplied and if they are valid
- function to check if login is premium/is sufficient for streaming content with XBMC
- function to login with these details if necessary
agreed, lets make the 'check if urls are still up' function disable-able by a flag

Unbehagen Wrote:general link resolver module:
- function to find out what submodule this link belongs to (hotfile, megaup, etc.)
agreed

Unbehagen Wrote:- function to parse an HTML page for links of any known filehost that allows for streaming (valid account), direct resolving of URLs as an optional flag
- function to parse an HTML page for links of a specific file host, direct resolving optional
i suppose this would be good, but perhaps lets not prioritise dev on this, i kind of think this is the actual addon developers job, as he needs to specify the name and icon that goes with the videourl.

Unbehagen Wrote:- function to log in to all/one specific file host
- function to check which file hosts are available for streaming
- function to resolve a link or a list of links to streamable URLs
agreed

Unbehagen Wrote:the methods to resolve or filter URLs should also have the ability to return file names as they are not always contained in the unresolves URLs.
good idea, its easy to do a re.split on all the / in the url, and get the last block of text after the last /
which gives you the filename. ie. from www142.megauplo*d.com/blahb;ahfal/my_movie_name.avi you can get my_movie_name.avi

have you got a github account? i can give you access.
if you havn't used git before, its really neat for collaborative dev once you get the hang of it.
Thanks for the feedback. I never used git before, mostly used svn because I've been too lazy to learn another version control thing. Anyway, my github username is unbehagen. I can't promise to submit a lot of code as I'm periodically quite busy with my dissertation and just do this for productive procrastination.

A few thoughts about the design:
Maybe the modules should provide simple methods like "resolve this url and give me a URL as a string " and complex methods that provide an icon (if available, logo of filehost otherwise), the resolved URL and the filename and possibly other meta information as a playlist item directly?
i actually learned how to use git before svn, weird or what. i'll add you to the repo.
its actually a bit easier, but its very similiar.
yeah, i won't be working on it much either as i have essays/exams over the next months.
but it shouldnt be that complicated to code.

in megaroutines i return the data as a tuple (or is it a list? i'm not sure of the exact name)
but it works as so:
if videolink = the_returned_data
videolink[0] is the resolved url
videolink[1] is something else
and so on....
i think this is better than two separate methods, which gives us more work.
Hey anarch,
please have a look at this first draft of the file host specific module interface:
http://pastebin.com/sRx3xP03
Edit: Or better, let's work on it using this: http://collabedit.com/xmu5w
Well, as it is an interface, it should probably raise exceptions instead of returning data. I wrote it this way to make it more understandable what the functions actually do.
well i like it so far, your code is neat and understandable.
if we get the interface really solid, and add support for a few video hosts, we can then make sure it's easy for addon devs to add support for more videohosts, to ensure it grows.

i added a path class + function that should be universally used by all sub modules in videoresolver, when storing cookies and other bits of data.
@unbehagan
i'm calling the general all-purpose resolver .py the 'master handler'
and the specific file hoster .py the 'specific handler'
if you can think up better names let me know!

my idea is to standardise the general structure of the specific handlers
so they can be used interchangeably from the master handler

this could be done by adding a standardised 'controller' class (my term, means nothing special in python) to each one...
this class would have a function for login, another for resolve etc
...making it easy to backport the various login and resolving functions people have written, by calling them from the functions in the 'controller' class, so we can leave their code untouched and not get bored to death rewriting them all.

this would also mean that if people only want to deal with only one specific handler, they don't have to use the master handler.

hope that makes sense, i'm sure i wouldn't understand myself either.
anarchintosh Wrote:this could be done by adding a standardised 'controller' class (my term, means nothing special in python) to each one...
that was actually the idea behind the FileHostModule - it is what you call the specific handler. It is the standard interface from which all individual classes inherit from and overwrite the methods to match the specific host.
anarchintosh Wrote:this class would have a function for login, another for resolve etc
...making it easy to backport the various login and resolving functions people have written, by calling them from the functions in the 'controller' class, so we can leave their code untouched and not get bored to death rewriting them all.
this would also mean that if people only want to deal with only one specific handler, they don't have to use the master handler.
exactly that is the idea.
Pages: 1 2 3