Videopremium resolver

ghizzu

New member
May 21, 2012
7
0
0
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 ''
 

baci

New member
May 13, 2012
1,474
0
0
Toronto, Canada
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 ''
Would you be kind enough to share some good Italian movie addons or streams. Thanks in advance.
 

Eldorado

Moderator
Staff member
May 7, 2012
990
0
16
Good stuff! Would be good if you could submit this to the repo - https://github.com/Eldorados/script.module.urlresolver

A couple things should be changed though:

- wrap the code in get_media_url() with try:except - this is the most likely point of failure, and in case of failure return self.unresolvable()
- use addon.log instead of print statements
- is there any way to grab the rtmp and swf values dynamically rather than hard coding?
 

ghizzu

New member
May 21, 2012
7
0
0
Good stuff! Would be good if you could submit this to the repo - https://github.com/Eldorados/script.module.urlresolver

A couple things should be changed though:

- wrap the code in get_media_url() with try:except - this is the most likely point of failure, and in case of failure return self.unresolvable()
- use addon.log instead of print statements
- is there any way to grab the rtmp and swf values dynamically rather than hard coding?
If you wish, feel free to make the changes yourself and add it to the repo. I'm not familiar with git, sorry...
The rtmp link (e4.videopremium.net): I found it in the pelisalacarta addon, I don't know where it came from.
 
Last edited:

ghizzu

New member
May 21, 2012
7
0
0
any update on this?
Well, the resolver stopped working. I'm going mad since two days trying to fix it, but there's something weird about redirections in the videopremium web pages and I just don't get it. Any help?
 

massimo

New member
Nov 21, 2013
2
0
0
I did the first and the second change requested by Eldorado and I was going to create a pull request, but as it stopped working there's no point in doing it. I have no experience with python developer, I can't help with this unfortunately :(