def add_items(self):
        helper.start('EpisodeList.add_items')
        if self.links == []:
            return

        half_eps = 0
        episodes = []
        for link in self.links:
            num = link['data-base']  #.string.strip()
            url = link['href']
            if self.__is_half_episode(num):  # 1a and 1b
                half_eps += 1

            episodes.append((num, url))

        self.num_episodes = len(episodes)

        helper.log_debug(
            'We have effectively %d episodes with %d half episodes' %
            (self.num_episodes, half_eps))

        all_metadata = self.get_metadata(args.base_title)
        helper.log_debug('We have %d metadata entries' % len(all_metadata))
        offset = -1
        for idx, (name, url) in enumerate(episodes):
            if self.__is_half_episode(name):
                offset -= 1
            metadata = all_metadata[
                int(name) +
                offset] if int(name) + offset < len(all_metadata) else {
                    'title': name
                }
            icon, fanart = self._get_art_from_metadata(metadata)
            query = self._construct_query(url,
                                          'qualityPlayer',
                                          metadata,
                                          media_type=self.media_type)
            cm_items = self._get_contextmenu_items()
            if helper.get_setting('enable-metadata') == 'true':
                metadata['title'] = '%s - %s' % (name, metadata['title'])
            #helper.show_error_dialog(['',str(query)])
            helper.add_video_item(query,
                                  metadata,
                                  img=icon,
                                  fanart=fanart,
                                  contextmenu_items=cm_items)

        self._add_related_links()

        helper.set_content('episodes')
        helper.add_sort_methods(['episode', 'title'])
        helper.end_of_directory()
        helper.end('EpisodeList.add_items')
        return
Пример #2
0
 def add_directories(self, src):
     helper.start('LocalList.add_directories')
     helper.set_content('addons')
     for (name, query) in src:
         icon = query.get('icon', '')
         fanart = query.get('fanart', '')
         helper.add_directory(query,
                              infolabels={'title': name},
                              img=icon,
                              fanart=fanart,
                              total_items=len(src))
     helper.end_of_directory()
     helper.end('LocalList.add_directories')
     return
Пример #3
0
    def add_items(self, title_prefix=None):
        helper.start('MediaList.add_items')
        timestamper = t_s.TimeStamper('MediaList.add_items')
        end_dir = (title_prefix == None)
        title_prefix = title_prefix if title_prefix else ''
        if end_dir:
            helper.set_content('tvshows')
        mlinks = self.links[:-1] if self.has_next_page else self.links
        #helper.show_error_dialog(['',str(self.links)])
        # Grabbing metadata is a huge bottleneck, so grabbing it in parallel speeds up things
        self.links_with_metadata = [None] * len(mlinks)
        if helper.debug_metadata_threads():
            map(lambda x: self.worker(x), enumerate(mlinks))#mc_links)		
        else:
            #pool = threadpool.ThreadPool(4)
            #pool.map(self.worker, enumerate(mlinks))
            #pool.wait_completion()
            #helper.show_error_dialog(['',str(mlinks[0])])			
            #helper.show_error_dialog(['',str(self.media_type_list)])		
            pool = ThreadPool(8) # Sets the pool size to 4			
            pool.map(self.worker, enumerate(mlinks))
            pool.close() 
            pool.join() 			
						
        timestamper.stamp('Grabbing metadata with threads')
        #helper.show_error_dialog(['',str(self.links_with_metadata)])

        try:		
            for (name, url, metadata, media_type) in self.links_with_metadata:
                icon, fanart = self._get_art_from_metadata(metadata)
                query = self._construct_query(url, 'episodeList', metadata, name, media_type)		
                contextmenu_items = self._get_contextmenu_items(url, name, metadata, media_type)
                metadata['title'] = title_prefix + name # adjust title for sub and dub
                helper.add_directory(query, metadata, img=icon, fanart=fanart, contextmenu_items=contextmenu_items, total_items=len(mlinks))
        except: pass
        self._add_next_page_link()

        if end_dir:
            helper.end_of_directory()
        timestamper.stamp_and_dump('Adding all items')
        helper.end('MediaList.add_items')
Пример #4
0
    def add_items(self):
        helper.start('MovieList.add_items')
        helper.set_content('movies')

        for link in self.links:
            num = link.string.strip()
            url = link['href']
            # for now, assume media_type is always movie; ignore self.mismatch
            metadata = self.get_metadata(args.base_title)
            query = self._construct_query(url, 'qualityPlayer', metadata)
            #if helper.get_setting('enable-metadata') == 'true':			
            #    metadata['title'] = '%s - %s' % (name, metadata['title'])
            if (query['base_title'] == ''):
                query['base_title'] = args.base_title
            #helper.show_error_dialog(['',str(query)])	            			
            helper.add_video_item(query, metadata, img=args.icon, fanart=args.fanart, contextmenu_items=self._get_contextmenu_items())

        self._add_related_links()

        helper.end_of_directory()
        helper.end('MovieList.add_items')
        return
    def add_items(self):
        helper.start('SpecialsList.add_items')
        helper.set_content('episodes')

        icon, fanart = self._get_art_for_season0()

        for link in self.links:
            num = link.string.strip()
            url = link['href']
            metadata = self.get_metadata(args.base_title + ' - ' + num)
            query = self._construct_query(url, 'qualityPlayer', metadata)
            helper.add_directory(
                query,
                metadata,
                img=args.icon,
                fanart=args.fanart,
                contextmenu_items=self._get_contextmenu_items())

        self._add_related_links()

        helper.end_of_directory()
        helper.end('SpecialsList.add_items')
        return