예제 #1
0
class MovshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "movshare"
    domains = ["movshare.net"]
    pattern = '//((?:www\.|embed\.)?movshare\.net)/(?:mobile/video\.php\?id=|video/|embed\.php\?v=)([0-9a-z]+)'

    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):
        web_url = self.get_url(host, media_id)
        self.net.http_HEAD(web_url)
        html = self.net.http_GET(web_url).content
        """movshare can do both flv and avi. There is no way I know before hand
        if the url going to be a flv or avi. So the first regex tries to find
        the avi file, if nothing is present, it will check for the flv file.
        "param name="src" is for avi
        "flashvars.file=" is for flv
        """
        r = re.search('<param name="src" value="(.+?)"', html)
        if not r:
            match = re.search('flashvars.filekey="(.+?)";', html)
            if match:
                #get stream url from api
                filekey = match.group(0)
                api = 'http://www.movshare.net/api/player.api.php?key=%s&file=%s' % (
                    filekey, media_id)
                html = self.net.http_GET(api).content
                r = re.search('url=(.+?)&title', html)
        if r:
            stream_url = r.group(1)
        else:
            raise UrlResolver.ResolverError('File Not Found or removed')

        return stream_url

    def get_url(self, host, media_id):
        return 'http://www.movshare.net/video/%s' % media_id

    def get_host_and_id(self, url):
        r = re.search(self.pattern, url)
        if r:
            return r.groups()
        else:
            return False

    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        return re.search(self.pattern, url) or 'movshare' in host
class MovshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "movshare"
    domains = ["movshare.net"]
    pattern = "//((?:www\.|embed\.)?movshare\.net)/(?:mobile/video\.php\?id=|video/|embed\.php\?v=)([0-9a-z]+)"

    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):
        web_url = self.get_url(host, media_id)
        self.net.http_HEAD(web_url)
        html = self.net.http_GET(web_url).content
        """movshare can do both flv and avi. There is no way I know before hand
        if the url going to be a flv or avi. So the first regex tries to find
        the avi file, if nothing is present, it will check for the flv file.
        "param name="src" is for avi
        "flashvars.file=" is for flv
        """
        r = re.search('<param name="src" value="(.+?)"', html)
        if not r:
            match = re.search('flashvars.filekey="(.+?)";', html)
            if match:
                # get stream url from api
                filekey = match.group(0)
                api = "http://www.movshare.net/api/player.api.php?key=%s&file=%s" % (filekey, media_id)
                html = self.net.http_GET(api).content
                r = re.search("url=(.+?)&title", html)
        if r:
            stream_url = r.group(1)
        else:
            raise UrlResolver.ResolverError("File Not Found or removed")

        return stream_url

    def get_url(self, host, media_id):
        return "http://www.movshare.net/video/%s" % media_id

    def get_host_and_id(self, url):
        r = re.search(self.pattern, url)
        if r:
            return r.groups()
        else:
            return False

    def valid_url(self, url, host):
        if self.get_setting("enabled") == "false":
            return False
        return re.search(self.pattern, url) or "movshare" in host
예제 #3
0
class MovshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "movshare"

    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):
        web_url = self.get_url(host, media_id)
        """ Human Verification """
        try:
            self.net.http_HEAD(web_url)
            html = self.net.http_GET(web_url).content
            """movshare can do both flv and avi. There is no way I know before hand
            if the url going to be a flv or avi. So the first regex tries to find 
            the avi file, if nothing is present, it will check for the flv file.
            "param name="src" is for avi
            "flashvars.file=" is for flv
            """
            r = re.search('<param name="src" value="(.+?)"', html)
            if not r:
                html = unwise.unwise_process(html)
                html = re.compile(r'eval\(function\(p,a,c,k,e,(?:d|r)\).+?\.split\(\'\|\'\).*?\)\)').search(html).group()
                html = jsunpack.unpack(html)
                filekey = unwise.resolve_var(html, "flashvars.filekey")
                
                #get stream url from api
                api = 'http://www.movshare.net/api/player.api.php?key=%s&file=%s' % (filekey, media_id)
                html = self.net.http_GET(api).content
                r = re.search('url=(.+?)&title', html)
            if r:
                stream_url = r.group(1)
            else:
                raise Exception ('File Not Found or removed')
            
            return stream_url
        except urllib2.URLError, e:
            common.addon.log_error(self.name + ': got http error %d fetching %s' %
                                   (e.code, web_url))
            common.addon.show_small_popup('Error','Http error: '+str(e), 5000, error_logo)
            return self.unresolvable(code=3, msg=e)
        except Exception, e:
            common.addon.log_error('**** Movshare Error occured: %s' % e)
            common.addon.show_small_popup(title='[B][COLOR white]MOVSHARE[/COLOR][/B]', msg='[COLOR red]%s[/COLOR]' % e, delay=5000, image=error_logo)
            return self.unresolvable(code=0, msg=e)
예제 #4
0
class MovshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "movshare"

    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):
        web_url = self.get_url(host, media_id)
        """ Human Verification """
        try:
            self.net.http_HEAD(web_url)
            html = self.net.http_GET(web_url).content
            """movshare can do both flv and avi. There is no way I know before hand
            if the url going to be a flv or avi. So the first regex tries to find 
            the avi file, if nothing is present, it will check for the flv file.
            "param name="src" is for avi
            "flashvars.file=" is for flv
            """
            r = re.search('<param name="src" value="(.+?)"', html)
            if not r:
                r = re.search('flashvars.file="(.+?)"', html)
            if r:
                stream_url = r.group(1)
            else:
                raise Exception('File Not Found or removed')

            return stream_url
        except urllib2.URLError, e:
            common.addon.log_error(self.name +
                                   ': got http error %d fetching %s' %
                                   (e.code, web_url))
            common.addon.show_small_popup('Error', 'Http error: ' + str(e),
                                          5000, error_logo)
            return False
        except Exception, e:
            common.addon.log_error('**** Movshare Error occured: %s' % e)
            common.addon.show_small_popup(
                title='[B][COLOR white]MOVSHARE[/COLOR][/B]',
                msg='[COLOR red]%s[/COLOR]' % e,
                delay=5000,
                image=error_logo)
            return False
class MovshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "movshare"
    domains = ["movshare.net"]

    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):
        web_url = self.get_url(host, media_id)
        print web_url
        """ Human Verification """
        try:
            self.net.http_HEAD(web_url)
            html = self.net.http_GET(web_url).content
            """movshare can do both flv and avi. There is no way I know before hand
            if the url going to be a flv or avi. So the first regex tries to find
            the avi file, if nothing is present, it will check for the flv file.
            "param name="src" is for avi
            "flashvars.file=" is for flv
            """
            r = re.search('<param name="src" value="(.+?)"', html)
            if not r:
                match = re.search('flashvars.filekey="(.+?)";', html)
                if match:
                    #get stream url from api
                    filekey = match.group(0)
                    api = 'http://www.movshare.net/api/player.api.php?key=%s&file=%s' % (filekey, media_id)
                    html = self.net.http_GET(api).content
                    r = re.search('url=(.+?)&title', html)
            if r:
                stream_url = r.group(1)
            else:
                raise Exception('File Not Found or removed')
            
            return stream_url
        except urllib2.HTTPError, e:
            common.addon.log_error(self.name + ': got http error %d fetching %s' %
                                   (e.code, web_url))
            return self.unresolvable(code=3, msg=e)
        except Exception, e:
            common.addon.log_error('**** Movshare Error occured: %s' % e)
            return self.unresolvable(code=0, msg=e)
예제 #6
0
class NowvideoResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "nowvideo"
    domains = ["nowvideo.eu", "nowvideo.ch", "nowvideo.sx"]

    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):
        web_url = self.get_url(host, media_id)
        try:
            html = self.net.http_GET(web_url).content
            key = re.compile('flashvars.filekey=(.+?);').findall(html)
            ip_key = key[0]
            pattern = 'var %s="(.+?)".+?flashvars.file="(.+?)"' % str(ip_key)
            r = re.search(pattern, html, re.DOTALL)
            if r:
                filekey, filename = r.groups()
            else:
                r = re.search('file no longer exists', html)
                if r:
                    raise Exception('File Not Found or removed')

            #get stream url from api
            api = 'http://www.nowvideo.sx/api/player.api.php?key=%s&file=%s' % (
                filekey, filename)
            html = self.net.http_GET(api).content
            r = re.search('url=(.+?)&title', html)
            if r:
                stream_url = urllib.unquote(r.group(1))
            else:
                r = re.search('no longer exists', html)
                if r:
                    raise Exception('File Not Found or removed')
                raise Exception('Failed to parse url')

            try:
                # test the url, should throw 404
                nv_header = self.net.http_HEAD(stream_url)
            except urllib2.HTTPError, e:
                # if error 404, redirect it back (two pass authentification)
                api = 'http://www.nowvideo.sx/api/player.api.php?pass=undefined&cid3=undefined&key=%s&user=undefined&numOfErrors=1&errorUrl=%s&cid=1&file=%s&cid2=undefined&errorCode=404' % (
                    filekey, urllib.quote_plus(stream_url), filename)
                html = self.net.http_GET(api).content
                r = re.search('url=(.+?)&title', html)
                if r:
                    stream_url = urllib.unquote(r.group(1))

            return stream_url
        except urllib2.HTTPError, e:
            common.addon.log_error('Nowvideo: got http error %d fetching %s' %
                                   (e.code, web_url))
            return self.unresolvable(code=3, msg=e)
class NowvideoResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "nowvideo"
    domains = [ "nowvideo.eu","nowvideo.ch","nowvideo.sx" ]

    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):
        web_url = self.get_url(host, media_id)
        try:
            html = self.net.http_GET(web_url).content
            key = re.compile('flashvars.filekey=(.+?);').findall(html)
            ip_key = key[0]
            pattern = 'var %s="(.+?)".+?flashvars.file="(.+?)"'% str(ip_key)
            r = re.search(pattern,html, re.DOTALL)
            if r:
                filekey, filename= r.groups()
            else:
                r = re.search('file no longer exists',html)
                if r:
                    raise Exception ('File Not Found or removed')
            
            #get stream url from api
            api = 'http://www.nowvideo.sx/api/player.api.php?key=%s&file=%s' % (filekey, filename)
            html = self.net.http_GET(api).content
            r = re.search('url=(.+?)&title', html)
            if r:
                stream_url = urllib.unquote(r.group(1))
            else:
                r = re.search('no longer exists',html)
                if r:
                    raise Exception ('File Not Found or removed')
                raise Exception ('Failed to parse url')
            
            try:
                # test the url, should throw 404
                nv_header = self.net.http_HEAD(stream_url)
            except urllib2.HTTPError, e:
                # if error 404, redirect it back (two pass authentification)
                api = 'http://www.nowvideo.sx/api/player.api.php?pass=undefined&cid3=undefined&key=%s&user=undefined&numOfErrors=1&errorUrl=%s&cid=1&file=%s&cid2=undefined&errorCode=404' % (filekey, urllib.quote_plus(stream_url), filename)
                html = self.net.http_GET(api).content
                r = re.search('url=(.+?)&title', html)
                if r:
                    stream_url = urllib.unquote(r.group(1))
                
            return stream_url
        except urllib2.HTTPError, e:
            common.addon.log_error('Nowvideo: got http error %d fetching %s' %
                                    (e.code, web_url))
            return self.unresolvable(code=3, msg=e)
class MovshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "movshare"

    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):
        web_url = self.get_url(host, media_id)
        """ Human Verification """
        try:
            self.net.http_HEAD(web_url)
            html = self.net.http_GET(web_url).content
            """movshare can do both flv and avi. There is no way I know before hand
            if the url going to be a flv or avi. So the first regex tries to find 
            the avi file, if nothing is present, it will check for the flv file.
            "param name="src" is for avi
            "flashvars.file=" is for flv
            """
            r = re.search('<param name="src" value="(.+?)"', html)
            if not r:
                r = re.search('flashvars.file="(.+?)"', html)
            if r:
                stream_url = r.group(1)
            else:
                raise Exception ('File Not Found or removed')
                                    
            return stream_url
        except urllib2.URLError, e:
            common.addon.log_error(self.name + ': got http error %d fetching %s' %
                                   (e.code, web_url))
            common.addon.show_small_popup('Error','Http error: '+str(e), 5000, error_logo)
            return False
        except Exception, e:
            common.addon.log_error('**** Movshare Error occured: %s' % e)
            common.addon.show_small_popup(title='[B][COLOR white]MOVSHARE[/COLOR][/B]', msg='[COLOR red]%s[/COLOR]' % e, delay=5000, image=error_logo)
            return False
class FlashstreamResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "flashstream"

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.resolver_host = "flashstream.in"

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)

        """ Human Verification """
        try:
            self.net.http_HEAD(web_url)
            html = self.net.http_GET(web_url).content
        except urllib2.URLError, e:
            common.addon.log_error(self.name + ': got http error %d fetching %s' %
                                  (e.code, web_url))
            return False

        """ Parsing HTML """
        sPattern = "<div id=\"player_code\">.*?<script type='text/javascript'>eval.*?return p}\((.*?)</script>"
        r = re.search(sPattern, html, re.DOTALL + re.IGNORECASE)
        if r:
            sJavascript = r.group(1)
            sUnpacked = jsunpack.unpack(sJavascript)
            #sPattern = '\'file\',\'([^\']+?)\''
            sPattern = '<param name="src"0="(.*?)"'
            r = re.search(sPattern, sUnpacked)
            if r:
                return r.group(1)
            else:
                common.addon.log_error(self.name + ": no video url found in %s" % sUnpacked)
        else:
            common.addon.log_error(self.name + ': no javascript pattern found')
        return False
예제 #10
0
class MovshareResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "movshare"

    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):
        web_url = self.get_url(host, media_id)
        """ Human Verification """
        try:
            self.net.http_HEAD(web_url)
            html = self.net.http_GET(web_url).content
        except urllib2.URLError, e:
            common.addon.log_error('movshare: got http error %d fetching %s' %
                                  (e.code, web_url))
            return False
               
        """movshare can do both flv and avi. There is no way I know before hand
        if the url going to be a flv or avi. So the first regex tries to find 
        the avi file, if nothing is present, it will check for the flv file.
        "param name="src" is for avi
        "flashvars.file=" is for flv
        """
        r = re.search('<param name="src" value="(.+?)"', html)
        if not r:
            r = re.search('flashvars.file="(.+?)"', html)
        if r:
            stream_url = r.group(1)
        else:
            common.addon.log_error('movshare: stream url not found')
            return False
                                    
        return stream_url
class FlashstreamResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "flashstream"

    def __init__(self):
        p = self.get_setting("priority") or 100
        self.priority = int(p)
        self.net = Net()
        self.resolver_host = "flashstream.in"

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)

        """ Human Verification """
        try:
            self.net.http_HEAD(web_url)
            html = self.net.http_GET(web_url).content
        except urllib2.URLError, e:
            common.addon.log_error(self.name + ": got http error %d fetching %s" % (e.code, web_url))
            return False

        """ Parsing HTML """
        sPattern = "<div id=\"player_code\">.*?<script type='text/javascript'>eval.*?return p}\((.*?)</script>"
        r = re.search(sPattern, html, re.DOTALL + re.IGNORECASE)
        if r:
            sJavascript = r.group(1)
            sUnpacked = jsunpack.unpack(sJavascript)
            # sPattern = '\'file\',\'([^\']+?)\''
            sPattern = '<param name="src"0="(.*?)"'
            r = re.search(sPattern, sUnpacked)
            if r:
                return r.group(1)
            else:
                common.addon.log_error(self.name + ": no video url found in %s" % sUnpacked)
        else:
            common.addon.log_error(self.name + ": no javascript pattern found")
        return False
예제 #12
0
class MyViRuResolver(Plugin,UrlResolver,PluginSettings):
    implements=[UrlResolver,PluginSettings]
    name="myviru"
    domains=[ "myvi.ru" ]
    pattern = '//((?:www\.)?myvi\.ru)/player/embed/html/([0-9a-zA-Z\-_]+)'

    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):
        full_url=self.get_url(host, media_id)
        src=self.net.http_GET(full_url).content
        p=re.findall("dataUrl:'([^']+)'",src)[0]
        js=json.loads(self.net.http_GET("http://%s%s" % (host, p)).content)
        videos=js["sprutoData"]["playlist"]
        opts=[]
        for video in videos:
            opts.append((video["title"], self.__resolve_url(video["video"][0]["url"], full_url)))
        return sorted(opts, key=lambda x:x[0])[0][1]

    def __resolve_url(self, url, ref_url):
        headers={'Referer':ref_url}
        return self.net.http_HEAD(url, headers=headers).get_url()

    def get_url(self,host,media_id):
        return 'http://%s/player/embed/html/%s'%(host, media_id)
     
    def get_host_and_id(self, url):
        r = re.search(self.pattern, 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.search(self.pattern, url) or 'myvi.ru' in host
예제 #13
0
class CloudyResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "cloudy.ec"
    domains = [
        "cloudy.ec", "cloudy.eu", "cloudy.sx", "cloudy.ch", "cloudy.com"
    ]

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()

    def __get_stream_url(self, media_id, filekey, error_num=0, error_url=None):
        '''
        Get stream url. 

        If previously found stream url is a dead link, add error params and try again
        '''

        if error_num > 0 and error_url:
            _error_params = '&numOfErrors={0}&errorCode=404&errorUrl={1}'.format(
                error_num,
                urllib.quote_plus(error_url).replace('.', '%2E'))
        else:
            _error_params = ''

        #use api to find stream address
        api_call = 'http://www.cloudy.ec/api/player.api.php?{0}&file={1}&key={2}{3}'.format(
            'user=undefined&pass=undefined', media_id,
            urllib.quote_plus(filekey).replace('.', '%2E'), _error_params)

        api_html = self.net.http_GET(api_call).content
        rapi = re.search('url=(.+?)&title=', api_html)
        if rapi:
            return urllib.unquote(rapi.group(1))

        return None

    def __is_stream_url_active(self, web_url):
        try:
            header = self.net.http_HEAD(web_url)
            if header.get_headers():
                return True

            return False
        except:
            return False

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        #grab stream details
        html = self.net.http_GET(web_url).content
        html = unwise.unwise_process(html)
        filekey = unwise.resolve_var(html, "vars.key")

        error_url = None
        stream_url = None
        # try to resolve 3 times then give up
        for x in range(0, 2):
            link = self.__get_stream_url(media_id,
                                         filekey,
                                         error_num=x,
                                         error_url=error_url)

            if link:
                active = self.__is_stream_url_active(link)

                if active:
                    stream_url = urllib.unquote(link)
                    break
                else:
                    # link inactive
                    error_url = link
            else:
                # no link found
                raise UrlResolver.ResolverError('File Not Found or removed')

        if stream_url:
            return stream_url
        else:
            raise UrlResolver.ResolverError('File Not Found or removed')

    def get_url(self, host, media_id):
        return 'http://www.cloudy.ec/embed.php?id=%s' % media_id

    def get_host_and_id(self, url):
        r = re.search(
            '(https?://(?:www\.|embed\.)cloudy\.(?:ec|eu|sx|ch|com))/(?:video/|embed\.php\?id=)([0-9a-z]+)',
            url)
        if r:
            return r.groups()
        else:
            return False

    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        return re.match(
            'https?://(?:www\.|embed\.)cloudy\.(?:ec|eu|sx|ch|com)/(?:video/|embed\.php\?id=)([0-9a-z]+)',
            url) or 'cloudy.' in host
예제 #14
0
class VideoHutResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "videohut.to"
    
    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.pattern = 'http://www.(videohut.to)/(?:v\/|embed.php\?id=)([0-9a-z]+)'
    
    def get_url(self, host, media_id):
            return 'http://www.videohut.to/embed.php?id=%s' % (media_id)
    
    def get_host_and_id(self, url):
        r = re.search(self.pattern, url)
        if r: return r.groups()
        else: return False
    
    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        return re.match(self.pattern, url) or self.name in host
    
    def __get_stream_url(self, media_id, filekey, error_num=0, error_url=None):
        '''
        Get stream url. 

        If previously found stream url is a dead link, add error params and try again
        '''

        if error_num > 0 and error_url:
            _error_params = '&numOfErrors={0}&errorCode=404&errorUrl={1}'.format(
                                error_num, 
                                urllib.quote_plus(error_url).replace('.', '%2E')
                            )
        else:
            _error_params = ''

        #use api to find stream address
        api_call = 'http://www.videohut.to/api/player.api.php?{0}&file={1}&key={2}{3}'.format(
                        'user=undefined&pass=undefined',
                        media_id,
                        urllib.quote_plus(filekey).replace('.', '%2E'),
                        _error_params
                    )

        api_html = self.net.http_GET(api_call).content
        rapi = re.search('url=(.+?)&title=', api_html)
        if rapi:
            return urllib.unquote(rapi.group(1))

        return None

    def __is_stream_url_active(self, web_url):
        try:
            header = self.net.http_HEAD(web_url)
            if header.get_headers():
                return True

            return False
        except:
            return False

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        dialog = xbmcgui.Dialog()
        #grab stream details
        try:
            html = self.net.http_GET(web_url).content
            html = unwise.unwise_process(html)
            filekey = unwise.resolve_var(html, "flashvars.filekey")

            error_url = None
            stream_url = None
            # try to resolve 3 times then give up
            for x in range(0, 2):
                link = self.__get_stream_url(media_id, filekey, 
                                        error_num=x,
                                        error_url=error_url)

                if link:
                    active = self.__is_stream_url_active(link)

                    if active:
                        stream_url = urllib.unquote(link)
                        break;
                    else:
                        # link inactive
                        error_url = link
                else:
                    # no link found
                    raise Exception ('File Not Found or removed')

            if stream_url:
                return stream_url
            else:
                raise Exception ('File Not Found or removed')

        except urllib2.URLError, e:
            common.addon.log_error(self.name + ': got http error %d fetching %s' %
                                   (e.code, web_url))
            common.addon.show_small_popup('Error','Http error: '+str(e), 8000, error_logo)
            return self.unresolvable(code=3, msg=e)
        except Exception, e:
            common.addon.log('**** videohut Error occured: %s' % e)
            common.addon.show_small_popup(title='[B][COLOR white]videohut[/COLOR][/B]', msg='[COLOR red]%s[/COLOR]' % e, delay=5000, image=error_logo)
            return self.unresolvable(code=0, msg=e)
예제 #15
0
class VideorajResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "videoraj.ch"
    domains = [ "videoraj.ec", "videoraj.eu", "videoraj.sx", "videoraj.ch", "videoraj.com" , "videoraj.to"]

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()

    def __get_stream_url(self, host, media_id, filekey, error_num=0, error_url=None):
        '''
        Get stream url. 

        If previously found stream url is a dead link, add error params and try again
        '''

        if error_num > 0 and error_url:
            _error_params = '&numOfErrors={0}&errorCode=404&errorUrl={1}'.format(
                                error_num, 
                                urllib.quote_plus(error_url).replace('.', '%2E')
                            )
        else:
            _error_params = ''

        #use api to find stream address
        api_call = '%s/api/player.api.php?%s&file=%s&key=%s%s' % (host, 'user=undefined&pass=undefined', media_id, urllib.quote_plus(filekey).replace('.', '%2E'), _error_params)

        api_html = self.net.http_GET(api_call).content
        rapi = re.search('url=(.+?)&title=', api_html)
        if rapi:
            return urllib.unquote(rapi.group(1))

        return None

    def __is_stream_url_active(self, web_url):
        try:
            header = self.net.http_HEAD(web_url)
            if header.get_headers():
                return True

            return False
        except:
            return False

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        #grab stream details
        html = self.net.http_GET(web_url).content
        html = unwise.unwise_process(html)
        filekey = unwise.resolve_var(html, "vars.key")
        error_url = None
        stream_url = None
        # try to resolve 3 times then give up
        for x in range(0, 2):
            link = self.__get_stream_url(host, media_id, filekey, 
                                    error_num=x,
                                    error_url=error_url)

            if link:
                active = self.__is_stream_url_active(link)

                if active:
                    stream_url = urllib.unquote(link)
                    break
                else:
                    # link inactive
                    error_url = link
            else:
                # no link found
                raise UrlResolver.ResolverError('File Not Found or removed')

        if stream_url:
            return stream_url
        else:
            raise UrlResolver.ResolverError('File Not Found or removed')

    def get_url(self, host, media_id):
        return '%s/embed.php?id=%s' % (host, media_id)

    def get_host_and_id(self, url):
        r = re.search('(https?://(?:www\.|embed\.)videoraj\.(?:ec|eu|sx|ch|com|to))/(?:v(?:ideo)*/|embed\.php\?id=)([0-9a-z]+)', url)
        if r:
            return r.groups()
        else:
            return False

    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        return re.match('https?://(?:www\.|embed\.)videoraj\.(?:ec|eu|sx|ch|com|to)/(?:v(?:ideo)*/|embed\.php\?id=)([0-9a-z]+)', url) or 'videoraj' in host
class VideoHutResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "videohut.to"
    domains = [ "videohut.to" ]
    
    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.pattern = 'http://www.(videohut.to)/(?:v\/|embed.php\?id=)([0-9a-z]+)'
    
    def get_url(self, host, media_id):
            return 'http://www.videohut.to/embed.php?id=%s' % (media_id)
    
    def get_host_and_id(self, url):
        r = re.search(self.pattern, url)
        if r: return r.groups()
        else: return False
    
    def valid_url(self, url, host):
        return re.match(self.pattern, url) or self.name in host
    
    def __get_stream_url(self, media_id, filekey, error_num=0, error_url=None):
        '''
        Get stream url. 

        If previously found stream url is a dead link, add error params and try again
        '''

        if error_num > 0 and error_url:
            _error_params = '&numOfErrors={0}&errorCode=404&errorUrl={1}'.format(
                                error_num, 
                                urllib.quote_plus(error_url).replace('.', '%2E')
                            )
        else:
            _error_params = ''

        #use api to find stream address
        api_call = 'http://www.videohut.to/api/player.api.php?{0}&file={1}&key={2}{3}'.format(
                        'user=undefined&pass=undefined',
                        media_id,
                        urllib.quote_plus(filekey).replace('.', '%2E'),
                        _error_params
                    )

        api_html = self.net.http_GET(api_call).content
        rapi = re.search('url=(.+?)&title=', api_html)
        if rapi:
            return urllib.unquote(rapi.group(1))

        return None

    def __is_stream_url_active(self, web_url):
        try:
            header = self.net.http_HEAD(web_url)
            if header.get_headers():
                return True

            return False
        except:
            return False

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content
        html = unwise.unwise_process(html)
        filekey = unwise.resolve_var(html, "flashvars.filekey")

        error_url = None
        stream_url = None
        # try to resolve 3 times then give up
        for x in range(0, 2):
            link = self.__get_stream_url(media_id, filekey, error_num=x, error_url=error_url)
            if link:
                active = self.__is_stream_url_active(link)
                if active:
                    stream_url = urllib.unquote(link)
                    break
                else:
                    # link inactive
                    error_url = link
            else:
                # no link found
                raise UrlResolver.ResolverError('File Not Found or removed')

        if stream_url:
            return stream_url
        else:
            raise UrlResolver.ResolverError('File Not Found or removed')
예제 #17
0
class NowvideoResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "nowvideo"
    domains = ["nowvideo.eu", "nowvideo.ch", "nowvideo.sx", "nowvideo.co", "nowvideo.li"]
    pattern = '((?:http://|www.|embed.)?nowvideo.(?:eu|sx|ch|co|li))/(?:mobile/video\.php\?id=|video/|embed\.php\?.*?v=)([0-9a-z]+)'

    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):
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content
        key = re.compile('flashvars.filekey=(.+?);').findall(html)
        ip_key = key[0]
        pattern = 'var %s="(.+?)".+?flashvars.file="(.+?)"' % str(ip_key)
        r = re.search(pattern, html, re.DOTALL)
        if r:
            filekey, filename = r.groups()
        else:
            r = re.search('file no longer exists', html)
            if r:
                raise UrlResolver.ResolverError('File Not Found or removed')
        
        #get stream url from api
        api = 'http://www.nowvideo.sx/api/player.api.php?key=%s&file=%s' % (filekey, filename)
        html = self.net.http_GET(api).content
        r = re.search('url=(.+?)&title', html)
        if r:
            stream_url = urllib.unquote(r.group(1))
        else:
            r = re.search('no longer exists', html)
            if r:
                raise UrlResolver.ResolverError('File Not Found or removed')
            raise UrlResolver.ResolverError('Failed to parse url')
        
        try:
            # test the url, should throw 404
            self.net.http_HEAD(stream_url)
        except urllib2.HTTPError:
            # if error 404, redirect it back (two pass authentification)
            api = 'http://www.nowvideo.sx/api/player.api.php?pass=undefined&cid3=undefined&key=%s&user=undefined&numOfErrors=1&errorUrl=%s&cid=1&file=%s&cid2=undefined&errorCode=404' % (filekey, urllib.quote_plus(stream_url), filename)
            html = self.net.http_GET(api).content
            r = re.search('url=(.+?)&title', html)
            if r:
                stream_url = urllib.unquote(r.group(1))
            
        return stream_url

    def get_url(self, host, media_id):
        return 'http://embed.nowvideo.sx/embed.php?v=%s' % media_id

    def get_host_and_id(self, url):
        r = re.search(self.pattern, url)
        if r:
            return r.groups()
        else:
            return False

    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        return re.search(self.pattern, url) or 'nowvideo' in host
예제 #18
0
class CloudyResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "cloudy.ec"

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()

    def __get_stream_url(self, media_id, filekey, error_num=0, error_url=None):
        '''
        Get stream url. 

        If previously found stream url is a dead link, add error params and try again
        '''

        if error_num > 0 and error_url:
            _error_params = '&numOfErrors={0}&errorCode=404&errorUrl={1}'.format(
                                error_num, 
                                urllib.quote_plus(error_url).replace('.', '%2E')
                            )
        else:
            _error_params = ''

        #use api to find stream address
        api_call = 'http://www.cloudy.ec/api/player.api.php?{0}&file={1}&key={2}{3}'.format(
                        'user=undefined&pass=undefined',
                        media_id,
                        urllib.quote_plus(filekey).replace('.', '%2E'),
                        _error_params
                    )

        api_html = self.net.http_GET(api_call).content
        rapi = re.search('url=(.+?)&title=', api_html)
        if rapi:
            return urllib.unquote(rapi.group(1))

        return None

    def __is_stream_url_active(self, web_url):
        try:
            header = self.net.http_HEAD(web_url)
            if header.get_headers():
                return True

            return False
        except:
            return False

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        dialog = xbmcgui.Dialog()
        #grab stream details
        try:
            html = self.net.http_GET(web_url).content
            html = unwise.unwise_process(html)
            filekey = unwise.resolve_var(html, "flashvars.filekey")

            error_url = None
            stream_url = None
            # try to resolve 3 times then give up
            for x in range(0, 2):
                link = self.__get_stream_url(media_id, filekey, 
                                        error_num=x,
                                        error_url=error_url)

                if link:
                    active = self.__is_stream_url_active(link)

                    if active:
                        stream_url = urllib.unquote(link)
                        break;
                    else:
                        # link inactive
                        error_url = link
                else:
                    # no link found
                    raise Exception ('File Not Found or removed')

            if stream_url:
                return stream_url
            else:
                raise Exception ('File Not Found or removed')

        except urllib2.URLError, e:
            common.addon.log_error(self.name + ': got http error %d fetching %s' %
                                   (e.code, web_url))
            common.addon.show_small_popup('Error','Http error: '+str(e), 8000, error_logo)
            return self.unresolvable(code=3, msg=e)
        except Exception, e:
            common.addon.log('**** Cloudy Error occured: %s' % e)
            common.addon.show_small_popup(title='[B][COLOR white]CLOUDY[/COLOR][/B]', msg='[COLOR red]%s[/COLOR]' % e, delay=5000, image=error_logo)
            return self.unresolvable(code=0, msg=e)