当前位置: 首页>>代码示例>>Python>>正文


Python Net.set_user_agent方法代码示例

本文整理汇总了Python中t0mm0.common.net.Net.set_user_agent方法的典型用法代码示例。如果您正苦于以下问题:Python Net.set_user_agent方法的具体用法?Python Net.set_user_agent怎么用?Python Net.set_user_agent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在t0mm0.common.net.Net的用法示例。


在下文中一共展示了Net.set_user_agent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AllVidResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class AllVidResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "allvid"
    domains = ["allvid.ch"]

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.pattern = 'http://(allvid\.ch)/(?:embed-)(.+?)(?:-|/|\.|$)'
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_url(self, host, media_id):
        return 'http://%s/embed-%s.html' % (host, 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 host in self.domains

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        self.headers['Referer'] = web_url
        html = self.net.http_GET(web_url, headers=self.headers).content
        r = re.search('sources\s*:\s*\[\s*\{\s*file\s*:\s*["\'](.+?)["\']', html)
        if r:
            return r.group(1)
        else:
            raise UrlResolver.ResolverError('File not found')
开发者ID:waggy162512,项目名称:script.module.urlresolver,代码行数:36,代码来源:allvid.py

示例2: Mp4EdgeResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class Mp4EdgeResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "mp4edge.com"
    domains = ["mp4edge.com"]
    
    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.pattern = 'http://((?:.*?)mp4edge\.com)/stream/([0-9a-zA-Z]+)'
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_url(self, host, media_id):
        return 'http://%s/stream/%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
    
    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        return re.match(self.pattern, url) or host in self.domains
    
    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        self.headers['Referer'] = web_url
        html = self.net.http_GET(web_url, headers=self.headers).content
        r = re.search('file\s*:\s*["\'](.+?)["\']', html)
        if r:
            return r.group(1)
        else:
            raise UrlResolver.ResolverError('File not found')
开发者ID:msports,项目名称:mw,代码行数:37,代码来源:mp4edge.py

示例3: AaaaYucacheResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class AaaaYucacheResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "si_yucache.net"
    domains = ["yucache.net"]

    def __init__(self):
        p = self.get_setting("priority") or 99
        self.priority = int(p)
        self.pattern = "http://((?:www|embed)*\.*(?:yucache\.net))/((?:embed(?:_ext)*/)*[0-9a-zA-Z/\?_\-=]+)[&]*.*"
        self.net = Net()
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {"User-Agent": self.user_agent}

    def get_url(self, host, media_id):
        return "http://%s/%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

    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_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        stream_url = None
        self.headers["Referer"] = web_url
        html = self.net.http_GET(web_url, headers=self.headers).content
        r = re.search(
            "(?:playlist:|timer\s*=\s*null;).+?url\s*[:=]+\s*['\"]+(http://stream\..+?)['\"]+", html, re.DOTALL
        )
        if r:
            stream_url = urllib.unquote_plus(r.group(1))
            opener = urllib2.build_opener()
            opener.addheaders = [("User-agent", self.user_agent)]
            opener.addheaders = [("Referer", web_url)]
            try:
                """ Quick test for redirected stream_url """
                resp = opener.open(stream_url)
                if stream_url != resp.geturl():
                    stream_url = resp.geturl()
            except urllib2.HTTPError, e:
                if e.code == 403:
                    if stream_url != e.geturl():
                        stream_url = e.geturl()
                    else:
                        stream_url = None
        if stream_url:
            return self.__add_headers_for_kodi(stream_url)
        else:
            raise UrlResolver.ResolverError("File not found")
开发者ID:bialagary,项目名称:mw,代码行数:59,代码来源:si_yucache.py

示例4: AaaaVideo44Resolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class AaaaVideo44Resolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "si_video44.net"
    domains = ["video44.net", "easyvideo.me"]

    def __init__(self):
        p = self.get_setting('priority') or 99
        self.priority = int(p)
        self.net = Net()
        self.pattern = 'http://((?:www.)?(?:video44.net|easyvideo.me))/gogo/.*?file=([%0-9a-zA-Z\-_\.]+).*?'
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_url(self, host, media_id):
        media_id = re.sub(r'%20', '_', media_id)
        return 'http://%s/gogo/?sv=1&file=%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

    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_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        self.headers['Referer'] = web_url
        html = self.net.http_GET(web_url, headers=self.headers).content
        r = re.search('file\s*:\s*"(.+?)"', html)
        if not r:
            r = re.search('playlist:.+?url:\s*\'(.+?)\'', html, re.DOTALL)
        if r:
            if 'google' in r.group(1):
                return HostedMediaFile(url=r.group(1)).resolve()
            else:
                return self.__add_headers_for_kodi(r.group(1))
        else:
            raise UrlResolver.ResolverError('File not found')

    def __add_headers_for_kodi(self, url):
        _referer = urllib.quote_plus('http://%s/' % self.domains[0])
        _user_agent = urllib.quote_plus(self.net._user_agent)
        _connection_timeout = '60'
        _cookies = ''
        for _cookie in self.net._cj:
            _cookies += urllib.quote_plus('%s=%s;' % (_cookie.name, _cookie.value))
        if _cookies:
            return '%s|Referer=%s&User-Agent=%s&Connection-Timeout=%s&Cookie=%s' % \
                   (url, _referer, _user_agent, _connection_timeout, _cookies)
        else:
            return '%s|Referer=%s&User-Agent=%s&Connection-Timeout=%s' % \
                   (url, _referer, _user_agent, _connection_timeout)
开发者ID:bialagary,项目名称:mw,代码行数:57,代码来源:si_video44.py

示例5: ZeroCastResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class ZeroCastResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "zerocast"
    domains = ["zerocast.tv"]
    pattern = '(?://|\.)(zerocast\.tv)/((?:embed|(?:channels/)*chan(?:nel)*)\.php\?.*(?:a=[0-9]+|chan=[a-zA-Z0-9]+).*)'

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        self.headers['Referer'] = web_url
        stream_url = None
        if 'chan=' in web_url:
            html = self.net.http_GET(web_url, headers=self.headers).content
            r = re.search('<script\stype=[\'"]text/javascript[\'"]\ssrc=[\'"](.+?)[\'"]>', html)
            if r:
                web_url = r.group(1)
        r = re.search('.+?a=([0-9]+).+', web_url)
        if r:
            web_url = 'http://zerocast.tv/embed.php?a=%s&id=&width=640&height=480&autostart=true&strech=' % r.group(1)
            html = self.net.http_GET(web_url, headers=self.headers).content
            r = re.search('file\s*:\s*["\'](.+?)["\']', html)
            if r:
                stream_url = r.group(1)
            else:
                r = re.search('curl\s*=\s*[\'"](.+?)[\'"]', html)
                if r:
                    try:
                        stream_url = r.group(1).decode('base64', 'strict')
                    except Exception:
                        raise UrlResolver.ResolverError('Failed to decode url')
        if stream_url:
            return stream_url
        else:
            raise UrlResolver.ResolverError('File not found')

    def get_url(self, host, media_id):
        return 'http://zerocast.tv/%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.search(self.pattern, url) or self.name in host
开发者ID:MrEntertainment,项目名称:script.module.urlresolver,代码行数:56,代码来源:zerocast.py

示例6: AaaaSextvXResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class AaaaSextvXResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "si_sextvx"
    domains = ["sextvx.com"]

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.pattern = 'http://.*?(sextvx\.com/[a-zA-Z]{2})/(?:embed|video|stream)/([0-9]+?)(?:-|$|/.*)'
        self.net = Net()
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_url(self, host, media_id):
        return 'http://%s/embed/%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

    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_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        headers = {'Referer': web_url}
        html = self.net.http_GET(web_url, headers=self.headers).content
        # http://www.sextvx.com/flux?d=web.flv&s=3&p=4,7,5,8,9,475894
        r = re.search('.*?<div id="player" path="(.+?),.+?\.(.+?)".*?', html)
        if r:
            s = r.group(1)
            p = r.group(2).replace('/', ',')
            web_url = 'http://www.sextvx.com/flux?d=web.flv&s=' + s + '&p=' + p
            stream_url = self.net.http_GET(web_url, headers=headers).content
            if stream_url:
                return self.__add_headers_for_kodi(stream_url)
        raise UrlResolver.ResolverError('File not found')

    def __add_headers_for_kodi(self, url):
        _referer = urllib.quote_plus('http://%s/' % self.domains[0])
        _user_agent = urllib.quote_plus(self.net._user_agent)
        _connection_timeout = '60'
        _cookies = ''
        for _cookie in self.net._cj:
            _cookies += urllib.quote_plus('%s=%s;' % (_cookie.name, _cookie.value))
        if _cookies:
            return '%s|Referer=%s&User-Agent=%s&Connection-Timeout=%s&Cookie=%s' % \
                   (url, _referer, _user_agent, _connection_timeout, _cookies)
        else:
            return '%s|Referer=%s&User-Agent=%s&Connection-Timeout=%s' % \
                   (url, _referer, _user_agent, _connection_timeout)
开发者ID:bialagary,项目名称:mw,代码行数:56,代码来源:si_sextvx.py

示例7: AaaaPlayVidResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class AaaaPlayVidResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "si_playvid"
    domains = ["playvid.com", "playvids.com"]

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.pattern = 'http://(.*?playvids*\.com)/(?:embed|watch/)(.+)'
        self.priority = int(p)
        self.net = Net()
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_url(self, host, media_id):
        return 'http://%s/embed/%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

    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_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        self.headers['Referer'] = web_url
        html = self.net.http_GET(web_url, headers=self.headers).content
        r = re.search('<embed\s*(?:data-href-html5=".+?"\s*)?type="application/x-shockwave-flash"(.+?)/>', html)
        if r:
            s = urllib2.unquote(r.group(1).replace('&amp;', '&'))
            r = re.search('.*?video_vars\[video_url_default\]=(.+?)&.*', s)
            if r:
                r = re.search('.*?video_vars\[video_urls\]\[' + re.escape(r.group(1)) + '\]=(.+?)&.*', s)
                if r:
                    return self.__add_headers_for_kodi(r.group(1))
        raise UrlResolver.ResolverError('File not found')

    def __add_headers_for_kodi(self, url):
        _referer = urllib.quote_plus('http://%s/' % self.domains[0])
        _user_agent = urllib.quote_plus(self.net._user_agent)
        _connection_timeout = '60'
        _cookies = ''
        for _cookie in self.net._cj:
            _cookies += urllib.quote_plus('%s=%s;' % (_cookie.name, _cookie.value))
        if _cookies:
            return '%s|Referer=%s&User-Agent=%s&Connection-Timeout=%s&Cookie=%s' % \
                   (url, _referer, _user_agent, _connection_timeout, _cookies)
        else:
            return '%s|Referer=%s&User-Agent=%s&Connection-Timeout=%s' % \
                   (url, _referer, _user_agent, _connection_timeout)
开发者ID:bialagary,项目名称:mw,代码行数:55,代码来源:si_playvid.py

示例8: AaaaAnimeUploaderResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class AaaaAnimeUploaderResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "si_animeuploader"
    domains = ["animeuploader.com"]

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.pattern = 'http[s]*://(.*?(?:animeuploader)\.com)/embed\.php\?video=(.+?)(?:&.*|$)'
        self.net = Net()
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_url(self, host, media_id):
        return 'http://%s//embed.php?video=%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

    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        return re.match(self.pattern, url)

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content
        r = re.search('\s*?sources:\s*?\[\s*?\{\s*?file:\s*?[\'"](.+?)[\'"].*', html)
        if r:
            return self.__add_headers_for_kodi(r.group(1))
        else:
            raise UrlResolver.ResolverError('File not found')

    def __add_headers_for_kodi(self, url):
        _referer = urllib.quote_plus('http://%s/' % self.domains[0])
        _user_agent = urllib.quote_plus(self.net._user_agent)
        _connection_timeout = '60'
        _cookies = ''
        for _cookie in self.net._cj:
            _cookies += urllib.quote_plus('%s=%s;' % (_cookie.name, _cookie.value))
        if _cookies:
            return '%s|Referer=%s&User-Agent=%s&Connection-Timeout=%s&Cookie=%s' % \
                   (url, _referer, _user_agent, _connection_timeout, _cookies)
        else:
            return '%s|Referer=%s&User-Agent=%s&Connection-Timeout=%s' % \
                   (url, _referer, _user_agent, _connection_timeout)
开发者ID:bialagary,项目名称:mw,代码行数:50,代码来源:si_animeuploader.py

示例9: MediaPlayBoxResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class MediaPlayBoxResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver]
    name = "MediaPlayBox"
    domains = ["mediaplaybox.com"]
    pattern = '(?://|\.)(mediaplaybox\.com)/video/(.*)'

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.net.set_user_agent(common.IE_USER_AGENT)
        self.headers = {'User-Agent': common.IE_USER_AGENT}

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content
        patterns = [
            'property="og:video"\s+content="[^"]+\?f=([^"]+)',
            'itemprop="embedURL"\s+content="[^"]+\?f=([^"]+)',
            '<embed[^>]+src="[^"]+\?f=([^"]+)'
        ]
        for pattern in patterns:
            match = re.search(pattern, html)
            if match:
                xml = self.net.http_GET(match.group(1)).content
                root = ET.fromstring(xml)
                result = root.find('./video/src')
                if result is not None:
                    return result.text
        
        raise UrlResolver.ResolverError('Unable to find mediaplaybox video')

    def get_url(self, host, media_id):
        return 'http://mediaplaybox.com/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):
        return re.search(self.pattern, url) or self.name in host
开发者ID:MrEntertainment,项目名称:script.module.urlresolver,代码行数:46,代码来源:mediaplaybox.py

示例10: UsersCloudResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class UsersCloudResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "userscloud"
    domains = ["userscloud.com"]
    pattern = '(?://|\.)(userscloud\.com)/(?:embed-)?([0-9a-zA-Z/]+)'

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        stream_url = None
        self.headers['Referer'] = web_url
        html = self.net.http_GET(web_url, headers=self.headers).content
        r = re.search('>(eval\(function\(p,a,c,k,e,d\).+?)</script>', html, re.DOTALL)
        if r:
            js_data = jsunpack.unpack(r.group(1))

            stream_url = re.findall('<param\s+name="src"\s*value="([^"]+)', js_data)
            stream_url += re.findall('file\s*:\s*[\'|\"](.+?)[\'|\"]', js_data)
            stream_url = [i for i in stream_url if not i.endswith('.srt')]

            if stream_url:
                return stream_url[0]

        raise UrlResolver.ResolverError('File not found')

    def get_url(self, host, media_id):
        return 'https://%s/%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

    def valid_url(self, url, host):
        return re.search(self.pattern, url) or self.name in host
开发者ID:MrEntertainment,项目名称:script.module.urlresolver,代码行数:46,代码来源:userscloud.py

示例11: AllVidResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class AllVidResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "allvid"
    domains = ["allvid.ch"]
    pattern = '(?://|\.)(allvid\.ch)/(?:embed-)?([0-9a-zA-Z]+)'

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        self.headers['Referer'] = web_url
        html = self.net.http_GET(web_url, headers=self.headers).content

        for match in re.finditer('(eval\(function.*?)</script>', html, re.DOTALL):
            js_data = jsunpack.unpack(match.group(1))
            js_data = js_data.replace('\\\'', '\'')

            r = re.search('sources\s*:\s*\[\s*\{\s*file\s*:\s*["\'](.+?)["\']', js_data)

            if r:
                return r.group(1)
        else:
            raise UrlResolver.ResolverError('File not found')

    def get_url(self, host, media_id):
        return 'http://%s/embed-%s.html' % (host, 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.search(self.pattern, url) or self.name in host
开发者ID:MrEntertainment,项目名称:script.module.urlresolver,代码行数:44,代码来源:allvid.py

示例12: UsersCloudResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class UsersCloudResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "userscloud"
    domains = ["userscloud.com"]

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.pattern = 'https://(userscloud\.com)/(?:embed-)*([a-zA-Z0-9]+)[/|-|$]*'
        self.user_agent = common.IE_USER_AGENT
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_url(self, host, media_id):
        return 'https://%s/%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

    def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        return re.match(self.pattern, url) or host in self.domains

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        stream_url = None
        self.headers['Referer'] = web_url
        html = self.net.http_GET(web_url, headers=self.headers).content
        r = re.search('>(eval\(function\(p,a,c,k,e,d\).+?)</script>', html, re.DOTALL)
        if r:
            r = jsunpack.unpack(r.group(1))
            r = re.search('param\sname\s*=\s*[\'"]src[\'"]\s*value\s*=\s*[\'"](.+?)[\'"]', r)
            if r:
                stream_url = r.group(1)
        if stream_url:
            return stream_url
        else:
            raise UrlResolver.ResolverError('File not found')
开发者ID:msports,项目名称:mw,代码行数:43,代码来源:userscloud.py

示例13: UsersFilesResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class UsersFilesResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver]
    name = "UsersFiles"
    domains = ["usersfiles.com"]
    pattern = '(?://|\.)(usersfiles\.com)/(?:embed-)?([0-9a-zA-Z/]+)'

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.net.set_user_agent(common.IE_USER_AGENT)
        self.headers = {'User-Agent': common.IE_USER_AGENT}

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content
        match = re.search('<script[^>]*>(eval.*?)</script>', html, re.DOTALL)
        if match:
            js_data = jsunpack.unpack(match.group(1))

            stream_url = re.findall('<param\s+name="src"\s*value="([^"]+)', js_data)
            stream_url += re.findall('file\s*:\s*[\'|\"](.+?)[\'|\"]', js_data)
            stream_url = [i for i in stream_url if not i.endswith('.srt')]

            if stream_url:
                return stream_url[0]

        raise UrlResolver.ResolverError('Unable to find userfiles video')

    def get_url(self, host, media_id):
        return 'http://usersfiles.com/%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.search(self.pattern, url) or self.name in host
开发者ID:MrEntertainment,项目名称:script.module.urlresolver,代码行数:43,代码来源:usersfiles.py

示例14: UsersFilesResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class UsersFilesResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver]
    name = "UsersFiles"
    domains = ["usersfiles.com"]

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.pattern = 'http[s]*://((?:www\.)?usersfiles.com)/(.*)'
        self.net.set_user_agent(common.IE_USER_AGENT)
        self.headers = {'User-Agent': common.IE_USER_AGENT}

    def get_url(self, host, media_id):
        return 'http://usersfiles.com/%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 host in self.domains

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        html = self.net.http_GET(web_url).content
        match = re.search('<script[^>]*>(eval.*?)</script>', html, re.DOTALL)
        if match:
            js_data = jsunpack.unpack(match.group(1))
            print js_data
            match = re.search('<param\s+name="src"\s*value="([^"]+)', js_data)
            if match:
                return match.group(1)
        
        raise UrlResolver.ResolverError('Unable to find userfiles video')
开发者ID:msports,项目名称:mw,代码行数:39,代码来源:usersfiles.py

示例15: ZeroCastResolver

# 需要导入模块: from t0mm0.common.net import Net [as 别名]
# 或者: from t0mm0.common.net.Net import set_user_agent [as 别名]
class ZeroCastResolver(Plugin, UrlResolver, PluginSettings):
    implements = [UrlResolver, PluginSettings]
    name = "zerocast"
    domains = ["zerocast.tv"]

    def __init__(self):
        p = self.get_setting('priority') or 100
        self.priority = int(p)
        self.net = Net()
        self.pattern = 'http://(zerocast\.tv)/(?:embed|channel)\.php\?.*a=([0-9]+).+'
        # 'http://zerocast.tv/embed|channel.php?a=1875&id=&width=640&height=480&autostart=true&strech=
        self.user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko'
        self.net.set_user_agent(self.user_agent)
        self.headers = {'User-Agent': self.user_agent}

    def get_url(self, host, media_id):
        return 'http://zerocast.tv/embed.php?a=%s&id=&width=640&height=480&autostart=true&strech=' % 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 host in self.domains

    def get_media_url(self, host, media_id):
        web_url = self.get_url(host, media_id)
        self.headers['Referer'] = web_url
        html = self.net.http_GET(web_url, headers=self.headers).content
        r = re.search('file\s*:\s*["\'](.+?)["\']', html)
        if r:
            return r.group(1)
        else:
            raise UrlResolver.ResolverError('File not found')
开发者ID:iamfreetofly,项目名称:repository.iamfreetofly-xbmc-repaddon-bb,代码行数:38,代码来源:zerocast.py


注:本文中的t0mm0.common.net.Net.set_user_agent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。