コード例 #1
0
    def twist_resolver(self, link):
        #Setup
        new_link = link.replace('magictwist.wm/', '')
        new_link = json.loads(new_link)

        #Decrypt
        decrypt_url = TwistDecrypt().decrypt(
            new_link['source'].encode('utf-8'),
            b"LXgIVP&PorO68Rq7dTx8N^lP!Fa5sGJ^*XK").decode('utf-8')

        file_name = decrypt_url.split('/')[-1].replace(
            decrypt_url.split('.')[-1], '')
        decrypt_url = decrypt_url.replace(file_name, tools.quote(file_name))

        stream_url = 'https://at-cdn.bunny.sh' + decrypt_url
        headers = {
            'Referer':
            tools.quote(
                'https://twist.moe/a/{slug}/{episode}'.format(**new_link)),
            'User-Agent':
            tools.quote(tools.get_random_ua()),
        }
        location = requests.head(stream_url,
                                 headers=headers).headers['location']

        location += '|User-Agent={User-Agent}&Referer={Referer}'.format(
            **headers)

        self.resolved_link = location
コード例 #2
0
 def franchise(self, args, page):
     show_info = json.loads(tools.unquote(args))
     anime = kitsu_api.KitsuBrowser().franchise(id=show_info['id'])
     self.list_builder(anime)
     if len(anime) == 20:
         tools.addDirectoryItem('Next Page...',
                                'franchise&page=%s' % str(page + 1),
                                None,
                                None,
                                actionArgs=tools.quote(tools.unquote(args)))
     tools.closeDirectory('episodes')
コード例 #3
0
ファイル: anime.py プロジェクト: N2Roar/roar-repository
    def list_builder_alt(self, anime, site):
        for a in anime:
            name_choice = tools.getSetting('show.titles')
            name = a['titles']['base']
            if name_choice == 'English':
                name = a['titles']['english']
            elif name_choice == 'Kanji':
                name = a['titles']['japanese']
            
            if name is None:
                name = a['titles']['canon']
                
            if a['titles']['japanese'] is not None:
                originaltitle = a['titles']['japanese'].encode('utf-8')
            else:
                originaltitle = ''      
                
            duration = 1

            item = {'plot': a['plot'],
                    'genre': a['genres'],
                    'year': a['year'],
                    'originaltitle': originaltitle,
                    'duration': str(duration*60),
                    'country': 'Japan'}       

            if a['subtype'] == 'Movie':
                action = 'play_anime&get_anime_info=true&site=%s' % site
                folder = False
                playable = True
                cm = [('Source Select', 'PlayMedia(%s?action=play_anime&source_select=true&actionArgs=%s)' % (sysaddon, tools.quote(json.dumps(a, sort_keys=True))))]
                item['mediatype'] = 'movie'
                item['title'] = name
            else:
                action = 'episode_list&get_anime_info=true&site=%s' % site
                folder = True
                playable = False
                cm = []
                item['mediatype'] = 'tvshow'
                item['tvshowtitle'] = name
                item['status'] = a['status']

            args = tools.quote(json.dumps(a, sort_keys=True))
            
            art = {'poster': a['picture']}
 
            tools.addDirectoryItem(name, action, item, art, cm=cm, isFolder=folder, isPlayable=playable, actionArgs=args)                     
コード例 #4
0
    def add_last_watched(self):
        a = kitsu_api.KitsuBrowser().getShow(self.last_watched)
        
        name_choice = tools.getSetting('show.titles')
        name = a['titles']['canon']
        if name_choice == 'English':
            name = a['titles']['english']
        elif name_choice == 'Romaji':
            name = a['titles']['romaji']
        elif name_choice == 'Kanji':
            name = a['titles']['kanji'].encode('utf-8')
            
        if name is None:
            name = a['titles']['canon']
            
        name = 'Last Watched: %s' % name
        
        duration = 1
        status = 'ended'
            
        try: 
            duration = int(a['episode_count'])*int(a['episode_length'])
        except: 
            try:
                duration = int(a['episode_length'])
            except:
                duration = 0
                
        try:
            if a['status'] == 'current':
                status = 'returning series'
            elif a['status'] == 'finished':
                status = 'ended'
            else:
                status = 'in production'
        except:
            status = 'in production'

        originaltitle = ''

        if a['titles']['kanji'] is not None:
            originaltitle = a['titles']['kanji'].encode('utf-8')
        else:
            originaltitle = ''

        item = {'plot': a['plot'],
                'genre': ', '.join(a['genres']),
                'year': a['year'],
                'premiered': a['start_date'],
                'originaltitle': originaltitle,
                'userrating': a['average_rating'],
                'mpaa': a['age_rating'],
                'duration': str(duration*60),
                'country': 'Japan'}
            
        if a['subtype'] == 'movie':
            action = 'play_anime'
            folder = False
            playable = True
            cm = []
            item['mediatype'] = 'movie'
            item['title'] = name
        else:
            action = 'episode_list'
            folder = True
            playable = False
            cm = []
                
            item['mediatype'] = 'tvshow'
            item['tvshowtitle'] = name
            item['status'] = status

        if 'youtube_trailer' in a:
            item['trailer'] = tools.youtube_url % a['youtube_trailer']

        args = tools.quote(json.dumps(a, sort_keys=True))
 
        tools.addDirectoryItem(name, action, item, a['art'], cm=cm, isFolder=folder, isPlayable=playable, actionArgs=args)         
コード例 #5
0
    def sources(self, data):
        source_list = []

        for a in data:
            for b in a:

                site = 'WonderfulSubs'
                try:
                    provider = self.source_dict[b['source']]

                except KeyError:
                    continue

                audio = b['language'][:3].title()

                retrieve = b['retrieve_url']

                if type(retrieve) is list:
                    retrieve = b['retrieve_url'][0]

                url = '/api/v2/media/stream?code={}&platform=Kodi'.format(
                    tools.quote(retrieve))

                try:
                    urls = self._session.get(url).json()

                    urls = urls['urls']

                except KeyError:
                    continue
                except ValueError:
                    continue

                if not urls:
                    continue

                for c in urls:
                    try:
                        quality = ''
                        adaptive = False

                        if c['label'] == '360p':
                            quality = 360

                        elif c['label'] == '480p':
                            quality = 480

                        elif c['label'] == '720p':
                            quality = 720

                        elif c['label'] == '1080p':
                            quality = 1080

                        elif c['label'] == 'Auto (DASH)':
                            quality = 1080
                            adaptive = 'mpd'

                        elif c['label'] == 'Auto (HLS)':
                            quality = 1080
                            adaptive = 'hls'

                        elif c['label'] == 'HD':
                            quality = 720

                        subtitles = c.get('captions', {}).get('src')

                        source_dict = {
                            'site': site,
                            'source': provider,
                            'link': c.get('src', c.get('file')),
                            'quality': quality,
                            'audio_type': audio,
                            'adaptive': adaptive,
                            'subtitles': subtitles
                        }

                        if source_dict['link'] is None:
                            continue

                        source_list.append(source_dict)

                    except KeyError:
                        traceback.print_exc()
                        continue

        return source_list
コード例 #6
0
##EPISODES STUFF
if action == 'episode_list':
    progress_info = ''

    #Convert MAL/AniList to Kitsu item.
    if get_kitsu_item == True:
        from resources.lib.modules import accounts
        from resources.lib.modules import kitsu_api
        args = json.loads(tools.unquote(actionArgs))
        progress_info = args['account_info']
        tools.log(progress_info, 'error')
        kitsu_id = accounts.Mappings().get(site, args['id'], 'kitsu')
        extracted_info = kitsu_api.KitsuBrowser().getListById(
            [kitsu_id], progress=progress_info)[0]
        tools.log(extracted_info, 'error')
        actionArgs = tools.quote(json.dumps(extracted_info))
    else:
        args = json.loads(tools.unquote(actionArgs))
        progress_info = args['account_info']

    from resources.lib.menus import anime
    anime.List().episode_list(actionArgs, page, progress_info)

##PLAY
if action == 'play_anime':
    #Convert MAL/AniList to Kitsu item.
    if get_kitsu_item == True:
        from resources.lib.modules import accounts
        from resources.lib.modules import kitsu_api
        args = json.loads(tools.unquote(actionArgs))
        kitsu_id = accounts.Mappings().get(site, args['id'], 'kitsu')
コード例 #7
0
ファイル: anime.py プロジェクト: N2Roar/roar-repository
    def episode_list_builder(self, show, episode_list, progress=False, smartPlay=False, sourceSelect=False, audioType=False):
        reverse = tools.getSetting('ep.reverse')
        shownum = tools.getSetting('ep.number')
        
        ep_list = episode_list
        
        if reverse == 'true':
            ep_list = sorted(episode_list, key=lambda x: int(x['episodeNumber']), reverse=True)
        else:
            ep_list = sorted(episode_list, key=lambda x: int(x['episodeNumber']), reverse=False)
    
        index = 0
        
        smartplay_list = []
        
        try: progress = show['account_info']['progress']
        except: progress = 0
    
        for a in ep_list:
            name_choice = tools.getSetting('ep.titles')
            name = a['episode_title']
            if name_choice == 'English':
                name = a['alt_titles']['english']
            elif name_choice == 'Romaji':
                name = a['alt_titles']['romaji']
            elif name_choice == 'Kanji':
                name = a['alt_titles']['kanji'].encode('utf-8')
                
            if name is None:
                name = 'Episode %s' % str(a['episodeNumber'])
            
            if shownum == 'true':
                name = str(a['episodeNumber']) + ' - ' + name            
                
            action = 'play_anime'
            folder = False
            playable = True
                
            if sourceSelect != False:
                action += '&source_select=true'
            if audioType != False:
                action += '&audio_type=%s' % audioType
                
            try: duration = str(show['episode_length']*60)
            except: duration = '22'
            
            item = {'plot': a['episodePlot'], 
                    'premiered': a['airdate'],
                    'year': a['year'], 
                    'mediatype': 'episode', 
                    'duration': duration,
                    'episode': int(a['episodeNumber'])}
            
            if int(a['episodeNumber']) <= progress:
                 item['playcount'] = 1
            else:
                 item['playcount'] = 0
            
            poster = a['thumbnail']
            
            if poster is None:
                poster = show['art']['poster']
            
            art = {'poster': poster,
                   'fanart': show['art']['fanart']}
            
            args = dict(show)
            args.update(a)
            
            if tools.getSetting('smartplay.enable') == 'true' and smartPlay == False:
                cm = []
            else:
                source_select_cm = ('Source Select', 'PlayMedia(%s?action=play_anime&source_select=true&actionArgs=%s)' % (sysaddon, tools.quote(json.dumps(args, sort_keys=True))))
                play_sub_cm = ('Play Subbed', 'PlayMedia(%s?action=play_anime&audio_type=bub&actionArgs=%s)' % (sysaddon, tools.quote(json.dumps(args, sort_keys=True))))
                play_dub_cm = ('Play Dubbed', 'PlayMedia(%s?action=play_anime&audio_type=sub&actionArgs=%s)' % (sysaddon, tools.quote(json.dumps(args, sort_keys=True))))
                cm = [source_select_cm, play_sub_cm, play_dub_cm]
            
            args = tools.quote(json.dumps(args, sort_keys=True))            

            smartplay_list.append(tools.addDirectoryItem(name, action, item, art, cm=cm, isFolder=folder, isPlayable=playable, actionArgs=args, bulk_add=True))
            
        if smartPlay == True:
           return smartplay_list
        else:
           tools.addMenuItems(syshandle, smartplay_list, len(smartplay_list))