Used in many italian streaming sites. Enjoy.
Code:
'''
Videopremium urlresolver plugin
Copyright (C) 2013 ghizzu
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
from t0mm0.common.net import Net
from urlresolver.plugnplay.interfaces import UrlResolver
from urlresolver.plugnplay.interfaces import PluginSettings
from urlresolver.plugnplay import Plugin
import re
import urllib2, xbmcgui, time, xbmc,urllib, cookielib
from urlresolver import common
import os
from lib import jsunpack
net = Net()
class VideopremiumResolver(Plugin, UrlResolver, PluginSettings):
implements = [UrlResolver, PluginSettings]
name = "videopremium"
def __init__(self):
p = self.get_setting('priority') or 100
self.priority = int(p)
self.net = Net()
def get_media_url(self, host, media_id):
print 'Videopremium: in get_media_url %s %s' % (host, media_id)
url = self.get_url(host, media_id)
urlref=url
urlref=urllib.quote_plus(urlref)
txheaders = {'User-agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36', 'Host':'videopremium.tv','Connection':'keep-alive', 'Referer':url, 'Cache-Control':'max-age=0', 'Origin':'http://videopremium.tv'} # fake a user agent, some websites (like google) don't like automated exploration
req = urllib2.Request(url)
html = urllib2.urlopen(req).read()
fname = urllib.quote_plus(re.search('<input type="hidden" name="fname" value="(.+?)">', html).group(1))
postdata = 'op=download1&usr_login=&id='+media_id+'&fname='+fname+'&referer='+urlref+'&method_free=Watch+Free%21'
#print postdata
req = urllib2.Request(url, postdata, txheaders)
response = urllib2.urlopen(req)
html=response.read()
html = html.replace(chr(10),'').replace(chr(13),'')
link = InBetween(html,'"file":"','"')
server=InBetween(link,'rtmp://','/')
#print "Server: "+server
link = link.replace(server,"e4.videopremium.net")
p2pkey=InBetween(html,'p2pkey:"','"')
tcUrl="rtmp://e4.videopremium.net/play"
link = link+' app=play tcUrl='+tcUrl + ' swfUrl=http://videopremium.net/uplayer/uppod.swf live=0 pageUrl='+url+' playpath='+p2pkey
print link
return link
def get_url(self, host, media_id):
print 'videopremium: in get_url %s %s' % (host, media_id)
return 'http://videopremium.net/%s' % media_id
def get_host_and_id(self, url):
r = re.search('//(.+?)/([0-9a-zA-Z]+)',url)
if r:
return r.groups()
else:
return False
return('host', 'media_id')
def valid_url(self, url, host):
if self.get_setting('enabled') == 'false': return False
return (re.match('http://videopremium.(net|tv)/' +
'[0-9A-Za-z]+', url) or
'videopremium' in host)
def InBetween(source,s1,s2):
res=re.compile(s1+'(.+?)'+s2).findall(source)
if res:
return res[0]
else:
return ''