Пример #1
0
def liste():
    url = args['url'][0]
    oldurl = url
    if 'animeliste-2' in url:
        type = 'movie'
    else:
        type = 'serie'
    content = requests.get(oldurl).text
    match = re.findall('/><div><center>.*?</center></div><br></div></div>',
                       content)
    seiten = re.findall('<a href=".*?">(.*?)</a>', match[0])
    if seiten:
        seiten = seiten[-1]
    else:
        seiten = 1
    seite = 1
    seiten = int(seiten)
    while seite <= seiten:
        if not seite == 1:
            url = oldurl.replace('.html', '') + '-' + str(seite) + '.html'
            content = requests.get(url).text
        seite += 1
        match = re.findall(
            'preview".*?src="(.*?)".*?></a>.*?"title"><a href=".(/anime.*?html)" title="(.*?)">.*?Jahr</b>: (.*?)</span>.*?</div>.*?<div class="element">.*?<div class="meta_r" style=".*?">(.*?)</div>',
            content, re.DOTALL)
        for cover, url, name, year, plot in match:
            url = 'http://www.anime-tube.tv' + url
            content = requests.get(url).text
            try:
                plot = re.findall('<li><b>Beschreibung</b>: (.*?)</li>',
                                  content, re.DOTALL)[0]
            except:
                plot = 'Keine Beschreibung vorhanden'
            #plot = plot.replace("&hellip;","...")
            year = year.replace("<i>Unbekannt</i>", "...")
            libname = name
            name = name + ' ' + '(' + year + ')'
            cm = []
            u = sys.argv[0] + "?url=" + urllib.quote_plus(
                url) + "&name=" + urllib.quote_plus(
                    libname) + "&mode=" + urllib.quote_plus(
                        'add') + "&iconimage=" + urllib.quote_plus(
                            cover) + "&plot=" + urllib.quote_plus(plot)
            cm.append(('Zu Meine Anime hinzufuegen', "XBMC.RunPlugin(%s)" % u))
            u = sys.argv[0] + "?url=" + urllib.quote_plus(
                url) + "&name=" + urllib.quote_plus(
                    libname) + "&mode=" + urllib.quote_plus(
                        'add_to_library') + "&type=" + str(type)
            cm.append(('Zur Bibliothek hinzufuegen', "XBMC.RunPlugin(%s)" % u))
            if oldurl == 'http://www.anime-tube.tv/animeliste-5-all.html':
                addLink(name, url, 'play', cover, plot)
            else:
                addDir(name, url, 'folgen', cover, plot, cm=cm)
    xbmcplugin.endOfDirectory(pluginhandle)
Пример #2
0
def folgen():
    url = args['url'][0]
    content = requests.get(url).text
    match = re.findall("(/anime-.*?-.*?.html)'>", content)
    for url in match:
        url = 'http://www.anime-tube.tv' + url
        content = requests.get(url).text
        match = re.findall(
            '<div class="title"><a href=".(.*?)" title=".*?">(.*?)</a>',
            content)
        for url, name in match:
            url = 'http://www.anime-tube.tv' + url
            addLink(name, url, 'play', '', '')
    xbmcplugin.endOfDirectory(pluginhandle)
Пример #3
0
def add_to_library_2(url, anime, type):
    if type == 'movie':
        ordner = addon.getSetting('filme_ordner')
    else:
        ordner = addon.getSetting('serien_ordner')
    if ordner:
        content = requests.get(url).text
        match = re.findall("(/anime-.*?-.*?.html)'>", content)
        for url in match:
            url = 'http://www.anime-tube.tv' + url
            content = requests.get(url).text
            match = re.findall(
                '<div class="title"><a href=".(.*?)" title=".*?">(.*?)</a>',
                content)
            for url, name in match:
                url = 'http://www.anime-tube.tv' + url
                strmname = 's01.e' + name + '.strm'.strip()
                strmentry = 'plugin://plugin.video.animetube/?url=' + urllib.quote_plus(
                    url) + '&mode=play' + '&name=' + urllib.quote_plus(name)
                strm = os.path.join(ordner, anime, strmname)
                strm = xbmc.makeLegalFilename(strm)
                if not xbmcvfs.exists(os.path.dirname(strm)):
                    try:
                        try:
                            xbmcvfs.mkdirs(os.path.dirname(strm))
                        except:
                            os.path.mkdir(os.path.dirname(strm))
                    except:
                        xbmc.executebuiltin(
                            'Notification(Info: Konnte keinen Ordner erstellen!,)'
                        )
                old_strmentry = ''
                try:
                    f = xbmcvfs.File(strm, 'r')
                    old_strmentry = f.read()
                    f.close()
                except:
                    pass
                if strmentry != old_strmentry:
                    try:
                        file_desc = xbmcvfs.File(strm, 'w')
                        file_desc.write(strmentry)
                        file_desc.close()
                    except:
                        xbmc.executebuiltin(
                            'Notification(Info: Konnte keine Datei erstellen!,)'
                        )
    else:
        addon.openSettings()
Пример #4
0
 def user(self):
     headers = {
         'accept': 'application/vnd.identity-service+json; version=1.0',
         'content-type': 'application/json',
         'authorization': self.ACCESS_TOKEN
     }
     return requests.get(self.USER_URL, headers=headers).json()
 def user(self):
     headers = {
         'accept': 'application/json',
         'content-type': 'application/json',
         'authorization': 'Bearer ' + self.ACCESS_TOKEN
     }
     return requests.get(self.USER_URL, headers=headers).json()
Пример #6
0
 def json_request(self, url):
     r = requests.get(url, headers=self.headers)
     if r.headers.get('content-type', '').startswith('application/json'):
         return r.json()
     else:
         log('[eurosportplayer] error: json request failed with %s response' % (str(r.status_code)))
         return {}
Пример #7
0
 def json_request(self, url):
     r = requests.get(url, headers=self.headers)
     if r.headers.get('content-type', '').startswith('application/json'):
         return r.json()
     else:
         log('[%s] error: json request failed (%s)' %
             (addon_id, str(r.status_code)))
         return {}
Пример #8
0
 def token(self):
     encoded  = urllib.urlencode({'data':json.dumps(self.dvs), 'context':json.dumps(self.context)})
     tokenUrl = self.VIDEO_TOKEN + '?' + encoded
     r = requests.get(tokenUrl, headers=self.headers)
     if r.headers.get('content-type', '').startswith('application/json'):
         return r.json()
     else:
         return {}
Пример #9
0
 def get_data(self, url):
     r = requests.get(url, headers=self.headers, allow_redirects=True)
     if r:
         return r.text
     else:
         log('[%s] error: request failed (%s)' %
             (addon_id, str(r.status_code)))
         return ''
Пример #10
0
 def json_request(self, url):
     r = requests.get(url, headers=self.headers)
     if r.headers.get('content-type', '').startswith('application/json'):
         return r.json()
     else:
         log('[eurosportplayer] error: json request failed with %s response'
             % (str(r.status_code)))
         return {}
Пример #11
0
    def twitch(self, url):
        def time_to_sec(t):
            seconds = 0
            h = re.search('(\d+)h', t)
            m = re.search('(\d+)m', t)
            s = re.search('(\d+)s', t)
            if h:
                seconds += int(h.group(1)) * 60 * 60
            if m:
                seconds += int(m.group(1)) * 60
            if s:
                seconds += int(s.group(1))
            return seconds

        if 'channel=' in url:
            _id_ = url.split('channel=')[1]
            access = 'https://api.twitch.tv/api/channels/%s/access_token' % _id_
            hls = 'http://usher.twitch.tv/api/channel/hls/%s.m3u8?%s'
        elif 'video=' in url:
            _id_ = re.sub('http.*?video=v|&.*?$', '', url)
            start_point = time_to_sec(re.sub('http.*?&t=', '', url))
            info = requests.get('https://api.twitch.tv/api/videos/v%s' % _id_,
                                headers={
                                    'Client-ID':
                                    'jzkbprff40iqj646a697cyrvl0zt2m6'
                                }).json()
            duration = info.get('duration', 0)
            self.startpercent = str((100 * start_point) / duration)
            access = 'https://api.twitch.tv/api/vods/%s/access_token' % _id_
            hls = 'https://usher.ttvnw.net/vod/%s.m3u8?%s'
        elif 'clips' in url:
            data = requests.get(url).text
            quality_options = re.search('quality_options\s*:\s*\[(.*?)\]',
                                        data, re.DOTALL).group(1)
            self.resolved_url = re.search('"source"\s*:\s*"(.+?)"',
                                          quality_options).group(1)
            return
        data = requests.get(access,
                            headers={
                                'Client-ID': 'jzkbprff40iqj646a697cyrvl0zt2m6'
                            }).json()
        params = {'allow_source': 'true'}
        params['sig'] = data['sig']
        params['token'] = data['token']
        self.resolved_url = hls % (_id_, urllib.urlencode(params))
Пример #12
0
 def streams(self, url):
     headers = {
         'accept': 'application/vnd.media-service+json; version=1',
         'authorization': self.ACCESS_TOKEN
     }
     json_data = requests.get(url.format(scenario='browser'), headers=headers).json()
     if json_data.get('errors', ''):
         log('[{0}] {1}'.format(addon_id, utfenc(json_data['errors'][0][:100])))
     json_data['token'] = self.ACCESS_TOKEN
     return json_data
Пример #13
0
 def json_request(self, url):
     if self.post_data:
         r = requests.post(url, headers=self.headers, data=self.post_data, params=self.params)
     else:
         r = requests.get(url, headers=self.headers, params=self.params)
     if r.headers.get('content-type', '').startswith('application/json'):
         return r.json()
     else:
         log('[%s] error: json request failed with %s response' % (addon_id, str(r.status_code)))
         return {}
Пример #14
0
 def json_request(self, url):
     if self.post_data:
         r = requests.post(url, headers=self.headers, data=self.post_data, params=self.params)
     else:
         r = requests.get(url, headers=self.headers, params=self.params)
     if r.headers.get('content-type', '').startswith('application/json'):
         return r.json()
     else:
         log('[%s] error: json request failed with %s response' % (addon_id, str(r.status_code)))
         return {}
Пример #15
0
 def request(self, url):
     if self.POST_DATA:
         r = requests.post(url, headers=self.HEADERS, data=self.POST_DATA, params=self.PARAMS)
     else:
         r = requests.get(url, headers=self.HEADERS, params=self.PARAMS)
     if r.headers.get("content-type", "").startswith("application/json"):
         return r.json()
     else:
         if not r.status_code == 204:
             log("[%s] error: json request (%s, %s)" % (addon_id, str(r.status_code), r.headers.get("content-type", "")))
         return {}
Пример #16
0
 def hitbox(self, url):
     channel = re.sub('\?.+?$', '', url.split('embed/')[1])
     api = 'http://www.hitbox.tv/api/player/config/live/%s'
     data = requests.get(api % channel, headers={'Accept': 'application/json, text/plain, */*'}).json()
     bitrate = 0
     bitrates = data['playlist'][0]['bitrates']
     for i in bitrates:
         if bitrate < int(i['bitrate']):
             url = i['url']
             bitrate = int(i['bitrate'])
     self.resolved_url = url
Пример #17
0
 def token(self):
     encoded = urllib.urlencode({
         'data': json.dumps(self.dvs),
         'context': json.dumps(self.context)
     })
     tokenUrl = self.VIDEO_TOKEN + '?' + encoded
     r = requests.get(tokenUrl, headers=self.headers)
     if r.headers.get('content-type', '').startswith('application/json'):
         return r.json()
     else:
         return {}
Пример #18
0
def abc():
    url = args['url'][0]
    content = requests.get(url).text
    match = re.findall(
        '<a href=".(/animeliste.*?html)" class="cat-title">(.*?)</a>', content)
    for url, name in match:
        if 'all' in url:
            pass
        else:
            url = 'http://www.anime-tube.tv' + url
            addDir(name, url, 'liste', '', '')
    xbmcplugin.endOfDirectory(pluginhandle)
Пример #19
0
def play():
    u = args['url'][0]
    name = args['name'][0]
    headers = {
        'User-Agent':
        'Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
    }
    content = requests.get(u).text
    match = re.findall(
        'ani-stream.*?<iframe.*?src\s*=\s*(?:\'|")(.*?)(?:\'|")', content,
        re.DOTALL + re.IGNORECASE)
    if match:
        url = match[0]
        if not url.startswith('http'):
            if url.startswith('//'):
                url = 'http:%s' % url
            else:
                url = 'http://%s' % url
        if 'skystream' in url:
            headers.update({'Referer': u, 'Host': 'player.skystream.tv'})
            content = requests.get(url, headers=headers).text.replace('\\', '')
            match = re.findall('"redirect_url":"(.*?)"', content)
            if match:
                url = match[0]
        content = requests.get(url).text
        stream = re.findall("file\s*:\s*(?:'|\")(.+?)(?:\'|\")", content)
        if stream:
            try:
                r = requests.head(stream[0], headers=headers)
                if r.headers.get('location'):
                    stream = [r.headers.get('location')]
            except:
                pass
            stream = '%s|User-Agent=iPhone' % stream[0]
            listitem = xbmcgui.ListItem(path=stream)
            listitem.setInfo(type="video", infoLabels={"title": name})
            xbmcplugin.setResolvedUrl(pluginhandle, True, listitem)
        else:
            xbmc.executebuiltin('Notification(Info: Kein Stream gefunden,)')
Пример #20
0
 def streams(self, url):
     headers = {
         'accept': 'application/vnd.media-service+json; version=2',
         'authorization': self.ACCESS_TOKEN
     }
     data = requests.get(url.format(scenario='browser'), headers=headers).json()
     if data.get('errors'):
         msg = data['errors'][0]['code']
         self.plugin.log('[{0}] {1}'.format(self.plugin.addon_id, self.plugin.utfenc(msg)))
         if msg == 'not-entitled' or msg == 'access-token.invalid':
             self.profile()
     data['license_key'] = self.license_key()
     return data
Пример #21
0
def neu():
    url = args['url'][0]
    headers = {
        'User-Agent':
        'Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
    }
    content = requests.get(url, headers=headers).text
    match = re.findall(
        '<a href=".(/video.+?)".*?<img src=".(/cover.+?)".*?<div class="alt">(.+?)<',
        content, re.DOTALL)
    for url, cover, name in match:
        url = 'http://www.anime-tube.tv' + url
        cover = 'http://www.anime-tube.tv' + cover
        addLink(name, url, 'play', cover, '')
    xbmcplugin.endOfDirectory(pluginhandle)
Пример #22
0
 def request(self, url):
     if self.POST_DATA:
         r = requests.post(url,
                           headers=self.HEADERS,
                           data=self.POST_DATA,
                           params=self.PARAMS)
     else:
         r = requests.get(url, headers=self.HEADERS, params=self.PARAMS)
     if r.headers.get('content-type', '').startswith('application/json'):
         return r.json()
     else:
         if not r.status_code == 204:
             log('[%s] error: %s (%s, %s)' %
                 (addon_id, url, str(
                     r.status_code), r.headers.get('content-type', '')))
         return {}
Пример #23
0
 def request(self, url):
     if self.POST_DATA:
         r = requests.post(url,
                           headers=self.HEADERS,
                           data=self.POST_DATA,
                           params=self.PARAMS)
     else:
         r = requests.get(url, headers=self.HEADERS, params=self.PARAMS)
     if r.headers.get("content-type", "").startswith("application/json"):
         return r.json()
     else:
         if not r.status_code == 204:
             log("[%s] error: json request (%s, %s)" %
                 (addon_id, str(
                     r.status_code), r.headers.get("content-type", "")))
         return {}
Пример #24
0
    def request(self, url):
        self.HEADERS['Authorization'] = 'Bearer ' + self.TOKEN
        self.PARAMS['LanguageCode'] = self.LANGUAGE
        self.PARAMS['Country'] = self.COUNTRY

        if self.POST_DATA:
            r = requests.post(url, headers=self.HEADERS, data=self.POST_DATA, params=self.PARAMS)
            self.POST_DATA  = {}
        else:
            r = requests.get(url, headers=self.HEADERS, params=self.PARAMS)

        if r.headers.get('content-type', '').startswith('application/json'):
            return r.json()
        else:
            if not r.status_code == 204:
                self.plugin.log('[{0}] error: {1} ({2}, {3})'.format(self.plugin.addon_id, url, str(r.status_code), r.headers.get('content-type', '')))
            return {}
Пример #25
0
    def request(self, url):
        if self.POST_DATA:
            r = requests.post(url,
                              headers=self.HEADERS,
                              data=self.POST_DATA,
                              params=self.PARAMS)
            self.POST_DATA = {}
        else:
            r = requests.get(url, headers=self.HEADERS, params=self.PARAMS)

        if r.headers.get('content-type', '').startswith('application/json'):
            return r.json()
        else:
            if not r.status_code == 204:
                self.plugin.log('[{0}] error: {1} ({2}, {3})'.format(
                    self.plugin.addon_id, url, str(r.status_code),
                    r.headers.get('content-type', '')))
            return {}
Пример #26
0
 def unas_xml(self,id):
     r   = requests.get(id + '&format=iphone', headers=self.headers)
     if r:
         return r.text
     else:
         return ''
Пример #27
0
    def youtube(self, url):

        start_point = re.search('start=(\d+)', url)
        if start_point:
            self.seektime = int(start_point.group(1))
        _id_ = re.search('http.*?/embed/(.+?)(\?|$)', url)
        if _id_:
            _id_ = _id_.group(1)
            params = {
                'video_id': _id_,
                'eurl': 'https://youtube.googleapis.com/v/' + _id_,
                'ssl_stream': '1',
                'ps': 'default',
                'el': 'default'
            }
            url = 'https://www.youtube.com/get_video_info'
            data = requests.get(url, params=params).text
            params = dict(urlparse.parse_qsl(data))
            dash = params.get('dashmpd', '')
            hls = params.get('hlsvp', '')
            if dash:
                self.resolved_url = dash
            if hls and not self.resolved_url:
                self.resolved_url = hls

        if not self.resolved_url and _id_:
            from .signature.cipher import Cipher
            url = 'https://www.youtube.com/watch?v=%s' % (_id_)
            html = requests.get(url).text
            pos = html.find('<script>var ytplayer')
            if pos >= 0:
                html2 = html[pos:]
                pos = html2.find('</script>')
                if pos:
                    html = html2[:pos]

            re_match_js = re.search(r'\"js\"[^:]*:[^"]*\"(?P<js>.+?)\"', html)
            js = ''
            cipher = None
            if re_match_js:
                js = re_match_js.group('js').replace('\\', '').strip('//')
                cipher = Cipher(java_script_url=js)

            re_match = re.search(
                r'\"url_encoded_fmt_stream_map\"\s*:\s*\"(?P<url_encoded_fmt_stream_map>[^"]*)\"',
                html)
            if re_match:
                url_encoded_fmt_stream_map = re_match.group(
                    'url_encoded_fmt_stream_map')
                url_encoded_fmt_stream_map = url_encoded_fmt_stream_map.split(
                    ',')
                for value in url_encoded_fmt_stream_map:
                    value = value.replace('\\u0026', '&')
                    attr = dict(urlparse.parse_qsl(value))
                    url = attr.get('url', None)
                    if url:
                        url = urllib.unquote(attr['url'])
                        if 'signature' in url:
                            self.resolved_url = url
                            break
                        signature = ''
                        if attr.get('s', ''):
                            signature = cipher.get_signature(attr['s'])
                        elif attr.get('sig', ''):
                            signature = attr.get('sig', '')
                        if signature:
                            url += '&signature=%s' % signature
                            self.resolved_url = url
                            break
Пример #28
0
 def unas_xml(self,id):
     r = requests.get(id + '&format=iphone', headers=self.headers)
     if r:
         return r.text
     else:
         return ''
Пример #29
0
 def logout(self):
     r = requests.get('https://secure.wtatv.com/system/userlogout',
                      headers=self.HEADERS,
                      allow_redirects=False)
Пример #30
0
 def session(self):
     self.headers['cookie'] = self.cookie
     r = requests.get(self.v2 + 'session', headers=self.headers)
     self.cookie = r.headers.get('set-cookie', '')
     addon.setSetting('cookie', self.cookie)
Пример #31
0
 def request(self, url):
     return requests.get(url, headers=self.headers).text
Пример #32
0
 def archive(self):
     return requests.get(base_hltv + '/results', headers=self.headers).text
Пример #33
0
 def matches(self):
     return requests.get(base_hltv + '/matches', headers=self.headers).text
Пример #34
0
 def events(self):
     return requests.get(base_url + '/json/wtaEvents').json()
Пример #35
0
 def vod(self, url):
     return requests.get(base_url + url, headers=self.HEADERS).text
Пример #36
0
 def get_data(url):
     return requests.get(url, headers=self.HEADERS).text
Пример #37
0
 def get_data(self, url):
     r = requests.get(url, headers=self.headers, allow_redirects=True)
     if r:
         return r.text
     else:
         return ''