示例#1
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')
示例#2
0
    def scrape(self, args):
        info = json.loads(tools.unquote(args))
        
        try:
            title = info['episode_title']
            self.scrape_type = 'show'
        except:
            self.scrape_type = 'movie'

        if self.scrape_type == 'movie':
            scrape_data = {
                'titles': info['titles'],
                'mal_titles': info['mal_titles'],
                'year': info['year'], 
                'id':info['id']}
        else:
            scrape_data = {
                'titles': info['titles'],
                'mal_titles': info['mal_titles'],
                'year': info['year'],
                'season': info['seasonNumber'],
                'episode': info['episodeNumber'],
                'id': info['id']}
             
        from resources.lib.modules.Nectar import NectarScraper
        
        self.sources = NectarScraper().scrape(scrape_data)
        
        return self.sources
示例#3
0
    def preliminaryActions(self, args, ss, at):
        self.actionArgs = json.loads(tools.unquote(args))
        self.sourceSelect = ss
        self.audioType = at

        tools.cancelPlayback()
        tools.playList.clear()
    from resources.lib.menus import anime
    anime.List().top_by_season(season, year, page)

if action == 'franchise':
    from resources.lib.menus import anime
    anime.List().franchise(actionArgs, page)

##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
示例#5
0
 def episode_list(self, args, page, progress):
     show_info = json.loads(tools.unquote(args))
     episodes = kitsu_api.KitsuBrowser().all_episodes(id=show_info['id'])
     self.episode_list_builder(show_info, episodes, progress)
     tools.closeDirectory('episodes')
示例#6
0
    def play(self, data, args):
        #Set Up Metadata
        info = json.loads(tools.unquote(args))

        try:
            ep_num = info['episodeNumber']

            genre_string = ', '.join(info['genres'])

            metadata = {
                'title': info['episode_title'],
                'tvshowtitle': info['titles']['canon'],
                'season': info['seasonNumber'],
                'episode': info['episodeNumber'],
                'genre': genre_string,
                'year': info['airdate'][:4],
                'plot': info['episodePlot']
            }
        except:
            genre_string = ', '.join(info['genres'])

            metadata = {
                'title': info['titles']['canon'],
                'genre': genre_string,
                'year': info['year'],
                'plot': info['plot']
            }

        item = tools.menuItem(path=data['url'])
        item.setInfo(type='video', infoLabels=metadata)
        item.setArt(info['art'])
        item.setProperty('Video', 'true')
        item.setProperty('isPlayable', 'true')

        if data['adaptive'] != False and 'auengine' not in data['url']:
            item.setProperty('inputstreamaddon', 'inputstream.adaptive')
            item.setProperty('inputstream.adaptive.manifest_type',
                             data['adaptive'])

        tools.setSetting('anime.lastwatched', str(info['id']))

        try:
            if int(info['episodeNumber']) == int(info['episode_count']):
                kitsu_status = 'completed'
                mal_status = 2
                anilist_status = 'COMPLETED'
            else:
                kitsu_status = 'current'
                mal_status = 1
                anilist_status = 'CURRENT'
        except:
            kitsu_status = 'current'
            mal_status = 1
            anilist_status = 'CURRENT'

        try:
            if tools.getSetting('kitsu.access') != '' and tools.getSetting(
                    'kitsu.track') == 'true':
                accounts.Kitsu().track(info['id'], info['episodeNumber'],
                                       kitsu_status)
            if tools.getSetting('mal.sessionid') != '' and tools.getSetting(
                    'mal.track') == 'true':
                accounts.Mal().track(info['id'], info['episodeNumber'],
                                     mal_status)
            if tools.getSetting('ani.userid') != '' and tools.getSetting(
                    'ani.track') == 'true':
                accounts.Anilist().track(info['id'], info['episodeNumber'],
                                         anilist_status)
        except:
            if tools.getSetting('kitsu.access') != '' and tools.getSetting(
                    'kitsu.track') == 'true':
                accounts.Kitsu().track(info['id'], '1', 'current')
            if tools.getSetting('mal.sessionid') != '' and tools.getSetting(
                    'mal.track') == 'true':
                accounts.Mal().track(info['id'], '1', 2)
            if tools.getSetting('ani.userid') != '' and tools.getSetting(
                    'ani.track') == 'true':
                accounts.Anilist().track(info['id'], '1', 'COMPLETED')

        tools.resolvedUrl(syshandle, True, item)

        if data['subtitles'] != None:
            subtitle_link = data['subtitles']

            sub_file_ex = subtitle_link.split('.')
            sub_file_ex = sub_file_ex[int(len(sub_file_ex) - 1)]

            #subtitle_location = os.path.join(tools.subtitle_file, 'temp.%s' % sub_file_ex)
            subtitle_location = tools.subtitle_file

            if os.path.exists(subtitle_location):
                os.remove(subtitle_location)
            file = requests.get(subtitle_link)
            sub_data = file.text
            sub_data = sub_data.encode('utf-8')
            with open(subtitle_location, 'wb') as code:
                code.write(sub_data)
            tools.sleep(3000)
            tools.player().setSubtitles(subtitle_location)