def fuzz():
    ''' Get and call all fuzz modules '''

    # Get test directory in addon folder
    test_path = xbmc.translatePath(
        'special://home/addons/script.library.integration.tool/resources/test/'
    )

    # Add all test modules to fuzz suite
    loader = unittest.TestLoader()
    suite = unittest.TestSuite()
    suite.addTests(
        loader.discover(os.path.dirname(__file__), pattern='fuzz_*.py'))
    utils.log_msg('All fuzz tests: %s' % suite)

    # Run all unit tests and save to text file
    log_file = os.path.join(test_path, 'fuzz_report.txt')
    with open(log_file, "w") as f:
        result = unittest.TextTestRunner(f, verbosity=2).run(suite)

    if result.wasSuccessful():
        utils.notification('Fuzz successful')
    else:
        utils.notification('Fuzz failed')

    utils.log_msg('Fuzz result: %s' % result)
 def sync_single_tvshow(self, show_label, show_path):
     ''' Sync single tvshow directory and stage items '''
     STR_i_NEW_i_STAGED_i_MANAGED = utils.ADDON.getLocalizedString(32106)
     STR_i_NEW = utils.ADDON.getLocalizedString(32107)
     # Add synced directory to database
     self.dbh.add_synced_dir(show_label, show_path, 'single-tvshow')
     # Get everything inside tvshow path
     dir_items = utils.load_directory_items(show_path, recursive=True)
     # Get all items to stage
     items_to_stage = 0
     num_already_staged = 0
     num_already_managed = 0
     for dir_item in dir_items:
         item_label = dir_item['label']
         item_path = dir_item['file']
         if self.dbh.path_exists(item_path, 'staged'):
             num_already_staged += 1
             continue
         elif self.dbh.path_exists(item_path, 'managed'):
             num_already_managed += 1
             continue
         elif self.dbh.check_blocked(item_label, 'episode'):
             continue
         self.dbh.add_content_item(item_path, item_label, 'tvshow', show_label)
         items_to_stage += 1
     if num_already_staged > 0 or num_already_managed > 0:
         utils.notification(
             STR_i_NEW_i_STAGED_i_MANAGED %
             (items_to_stage, num_already_staged, num_already_managed)
         )
     else:
         utils.notification(STR_i_NEW % items_to_stage)
    def sync_movie_directory(self, dir_label, dir_path):
        ''' Sync movie directory and stage items '''
        STR_GETTING_ITEMS_IN_DIR = utils.ADDON.getLocalizedString(32125)
        STR_i_MOVIES_STAGED = utils.ADDON.getLocalizedString(32111)

        p_dialog = xbmcgui.DialogProgress()
        p_dialog.create(utils.ADDON_NAME)

        try:
            # Add synced directory to database
            self.dbh.add_synced_dir(dir_label, dir_path, 'movie')

            # Query json-rpc to get files in directory
            p_dialog.update(0, line1=STR_GETTING_ITEMS_IN_DIR)
            dir_items = utils.load_directory_items(dir_path, recursive=True)

            # Loop through all items and get titles and paths and stage them
            items_to_stage = 0
            for index, dir_item in enumerate(dir_items):
                # Get label & path for item
                item_label = dir_item['label']
                item_path = dir_item['file']
                if self.dbh.path_exists(item_path) or self.dbh.check_blocked(item_label, 'movie'):
                    continue
                # Update progress
                percent = 100 * index / len(dir_items)
                p_dialog.update(percent, line2=item_label)
                # Add item to database
                self.dbh.add_content_item(item_path, item_label, 'movie')
                items_to_stage += 1
                p_dialog.update(percent, line2=' ')
            utils.notification(STR_i_MOVIES_STAGED % items_to_stage)
        finally:
            p_dialog.close()
예제 #4
0
    def add_all_with_metadata(self):
        ''' Add all tvshow items with nfo file to library'''
        STR_ADDING_ALL_TV_SHOW_ITEMS_WITH_METADATA = utils.getlocalizedstring(
            32061)
        STR_ALL_TV_SHOW_ITEMS_WITH_METADATA_ADDED = utils.getlocalizedstring(
            32062)
        progress_dialog = xbmcgui.DialogProgress()
        progress_dialog.create(utils.ADDON_NAME,
                               STR_ADDING_ALL_TV_SHOW_ITEMS_WITH_METADATA)

        staged_tv_items = self.dbh.get_content_items(status='staged',
                                                     mediatype='tvshow',
                                                     order='Show_Title')
        # content menaget precisa retornar episode_nfo[0]
        for index, item in enumerate(staged_tv_items):
            percent = 100 * index / len(staged_tv_items)
            if os.path.exists(item.episode_nfo[0]):
                progress_dialog.update(percent,
                                       line2=item.show_title,
                                       line3=item.episode_title_with_id)
                xbmc.sleep(200)
                item.add_to_library()
            progress_dialog.update(percent, line2=' ', line3=' ')
        progress_dialog.close()
        utils.notification(STR_ALL_TV_SHOW_ITEMS_WITH_METADATA_ADDED)
예제 #5
0
    def add_all_seasons_with_metadata(self, show_title):
        ''' Add all seasons in the specified show with metadata to the library '''
        STR_ADDING_ALL_x_SEASONS_WITH_METADATA = 'Adding all %s seasons with metadata...'
        STR_ALL_x_SEASONS_WITH_METADATA_ADDED = 'All %s seasons with metadata added'
        staged_seasons = self.dbh.get_content_items(status='staged',
                                                    mediatype='tvshow',
                                                    order='Show_Title',
                                                    show_title=show_title)

        progress_dialog = xbmcgui.DialogProgress()
        progress_dialog.create(
            utils.ADDON_NAME,
            STR_ADDING_ALL_x_SEASONS_WITH_METADATA % show_title)
        for index, item in enumerate(staged_seasons):
            percent = 100 * index / len(staged_seasons)

            if os.path.exists(item.episode_nfo[0]):
                progress_dialog.update(percent,
                                       line2=item.show_title,
                                       line3=item.episode_title_with_id)
                xbmc.sleep(200)
                item.add_to_library()

            progress_dialog.update(percent, line2=' ', line3=' ')
        progress_dialog.close()
        utils.notification(STR_ALL_x_SEASONS_WITH_METADATA_ADDED % show_title)
 def remove_all(self):
     ''' Remove all synced directories '''
     STR_REMOVE_ALL_SYNCED_DIRS = utils.ADDON.getLocalizedString(32086)
     STR_ALL_SYNCED_DIRS_REMOVED = utils.ADDON.getLocalizedString(32087)
     STR_ARE_YOU_SURE = utils.ADDON.getLocalizedString(32088)
     if xbmcgui.Dialog().yesno('{0} - {1}'.format(utils.ADDON_NAME, STR_REMOVE_ALL_SYNCED_DIRS),
                               STR_ARE_YOU_SURE):
         self.dbh.remove_all_synced_dirs()
         utils.notification(STR_ALL_SYNCED_DIRS_REMOVED)
 def remove_all_episodes(self, show_title):
     ''' Remove all episodes from the specified show '''
     STR_REMOVING_ALL_x_EPISODES = utils.ADDON.getLocalizedString(32032) % show_title
     STR_ALL_x_EPISODES_REMOVED = utils.ADDON.getLocalizedString(32033) % show_title
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_x_EPISODES)
     self.dbh.remove_all_show_episodes('staged', show_title)
     progress_dialog.close()
     utils.notification(STR_ALL_x_EPISODES_REMOVED)
 def remove_all(self):
     ''' Remove all staged tvshow items '''
     STR_REMOVING_ALL_TV_SHOWS = utils.ADDON.getLocalizedString(32024)
     STR_ALL_TV_SHOW_REMOVED = utils.ADDON.getLocalizedString(32025)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_TV_SHOWS)
     self.dbh.remove_all_content_items('staged', 'tvshow')
     progress_dialog.close()
     utils.notification(STR_ALL_TV_SHOW_REMOVED)
 def remove_all(self):
     ''' Remove all staged movies '''
     STR_REMOVING_ALL_MOVIES = utils.ADDON.getLocalizedString(32013)
     STR_ALL_MOVIES_REMOVED = utils.ADDON.getLocalizedString(32014)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_MOVIES)
     self.dbh.remove_all_content_items('staged', 'movie')
     progress_dialog.close()
     utils.notification(STR_ALL_MOVIES_REMOVED)
예제 #10
0
def test():
    ''' Get and call all test modules and find coverage '''

    # Get test directory in addon folder
    test_path = xbmc.translatePath(
        'special://home/addons/script.library.integration.tool/resources/test/'
    )

    # Add all test modules to suite
    loader = unittest.TestLoader()
    suite = unittest.TestSuite()
    suite.addTests(
        loader.discover(os.path.dirname(__file__), pattern='test_*.py'))
    utils.log_msg('All unit tests: %s' % suite)

    # Attempt to load and start coverage module
    try:
        sys.path.append(
            '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages'
        )
        import coverage
    except ImportError:
        test_coverage = False
        utils.log_msg('Coverage module not available.', xbmc.LOGWARNING)
    else:
        test_path_wildcard = os.path.join(test_path, '*')
        cov = coverage.Coverage(omit=test_path_wildcard)
        cov.start()
        test_coverage = True
        utils.log_msg('Coverage module loaded.')

    # Run all unit tests and save to text file
    log_file = os.path.join(test_path, 'test_report.txt')
    with open(log_file, 'w') as f:
        result = unittest.TextTestRunner(f, verbosity=2).run(suite)

    # Stop coverage and save output
    if test_coverage:
        cov.stop()
        cov_folder = os.path.join(test_path, 'coverage')
        cov.html_report(directory=cov_folder)
        cov_txt_file = os.path.join(test_path, 'coverage.txt')
        with open(cov_txt_file, 'w') as f:
            cov.report(file=f)
        cov_xml_file = os.path.join(test_path, 'coverage.xml')
        cov.xml_report(outfile=cov_xml_file)
        utils.log_msg('Test coverage complete.')

    if result.wasSuccessful():
        utils.notification('Tests successful')
    else:
        utils.notification('Tests failed')

    utils.log_msg('Test result: %s' % result)
예제 #11
0
 def remove_all(self):
     ''' Remove all staged movies '''
     STR_REMOVING_ALL_MOVIES = utils.getlocalizedstring(32013)
     STR_ALL_MOVIES_REMOVED = utils.getlocalizedstring(32014)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_MOVIES)
     self.dbh.remove_from(status='staged',
                          mediatype='movie',
                          show_title=None,
                          directory=None)
     progress_dialog.close()
     utils.notification(STR_ALL_MOVIES_REMOVED)
 def add_all(items):
     ''' Add all staged movies to library '''
     STR_ADDING_ALL_MOVIES = utils.ADDON.getLocalizedString(32042)
     STR_ALL_MOVIES_ADDED = utils.ADDON.getLocalizedString(32043)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_ADDING_ALL_MOVIES)
     for index, item in enumerate(items):
         percent = 100 * index / len(items)
         progress_dialog.update(percent, line2=item.title)
         item.add_to_library()
     progress_dialog.close()
     utils.notification(STR_ALL_MOVIES_ADDED)
예제 #13
0
 def remove_all(self):
     ''' Remove all staged tvshow items '''
     STR_REMOVING_ALL_TV_SHOWS = utils.getlocalizedstring(32024)
     STR_ALL_TV_SHOW_REMOVED = utils.getlocalizedstring(32025)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_TV_SHOWS)
     self.dbh.remove_from(status='staged',
                          mediatype='tvshow',
                          show_title=None,
                          directory=None)
     progress_dialog.close()
     utils.notification(STR_ALL_TV_SHOW_REMOVED)
 def generate_all_episodes_metadata(items):
     ''' Generate metadata items for all episodes in show '''
     STR_GENERATING_ALL_x_METADATA = utils.ADDON.getLocalizedString(32077)
     STR_ALL_x_METADATA_CREATED = utils.ADDON.getLocalizedString(32078)
     show_title = items[0].show_title
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_GENERATING_ALL_x_METADATA % show_title)
     for index, item in enumerate(items):
         percent = 100 * index / len(items)
         progress_dialog.update(percent, line2=item.title)
         item.create_metadata_item()
     progress_dialog.close()
     utils.notification(STR_ALL_x_METADATA_CREATED % show_title)
 def add_all_episodes(items):
     ''' Add all episodes from specified show to library '''
     STR_ADDING_ALL_x_EPISODES = utils.ADDON.getLocalizedString(32071)
     STR_ALL_x_EPISODES_ADDED = utils.ADDON.getLocalizedString(32072)
     show_title = items[0].show_title
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_ADDING_ALL_x_EPISODES % show_title)
     for index, item in enumerate(items):
         percent = 100 * index / len(items)
         progress_dialog.update(percent, line2=item.title)
         item.add_to_library()
     progress_dialog.close()
     utils.notification(STR_ALL_x_EPISODES_ADDED % show_title)
예제 #16
0
 def move_all_to_staged(items):
     ''' Remove all managed movies from library, and add them to staged '''
     STR_MOVING_ALL_MOVIES_BACK_TO_STAGED = utils.ADDON.getLocalizedString(32015)
     STR_ALL_MOVIES_MOVED_TO_STAGED = utils.ADDON.getLocalizedString(32016)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_MOVING_ALL_MOVIES_BACK_TO_STAGED)
     for index, item in enumerate(items):
         percent = 100 * index / len(items)
         progress_dialog.update(percent, line2=item.title)
         item.remove_from_library()
         item.set_as_staged()
     progress_dialog.close()
     utils.notification(STR_ALL_MOVIES_MOVED_TO_STAGED)
예제 #17
0
 def remove_all(items):
     ''' Remove all managed movies from library '''
     STR_REMOVING_ALL_MOVIES = utils.ADDON.getLocalizedString(32013)
     STR_ALL_MOVIES_REMOVED = utils.ADDON.getLocalizedString(32014)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_MOVIES)
     for index, item in enumerate(items):
         percent = 100 * index / len(items)
         progress_dialog.update(percent, line2=item.title)
         item.remove_from_library()
         item.delete()
     progress_dialog.close()
     utils.notification(STR_ALL_MOVIES_REMOVED)
예제 #18
0
 def generate_all_metadata(items):
     ''' Generate metadata items for all staged movies '''
     STR_GENERATING_ALL_MOVIE_METADATA = utils.getlocalizedstring(32046)
     STR_ALL_MOVIE_METADTA_CREATED = utils.getlocalizedstring(32047)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME,
                            STR_GENERATING_ALL_MOVIE_METADATA)
     for index, item in enumerate(items):
         percent = 100 * index / len(items)
         progress_dialog.update(int(percent), item.movie_title)
         item.create_metadata_item()
     progress_dialog.close()
     utils.notification(STR_ALL_MOVIE_METADTA_CREATED)
예제 #19
0
    def sync_tvshow_directory(self, dir_label, dir_path):
        ''' Sync all TV shows in directory and stage items'''
        STR_GETTING_ITEMS_IN_DIR = utils.ADDON.getLocalizedString(32125)
        STR_GETTING_ITEMS_IN_x = utils.ADDON.getLocalizedString(32126)
        STR_i_EPISODES_STAGED = utils.ADDON.getLocalizedString(32112)

        p_dialog = xbmcgui.DialogProgress()
        p_dialog.create(utils.ADDON_NAME)

        try:
            # add synced directory to database
            self.dbh.add_synced_dir(dir_label, dir_path, 'tvshow')

            # query json-rpc to get files in directory
            p_dialog.update(0, line1=STR_GETTING_ITEMS_IN_DIR)
            dir_items = utils.load_directory_items(dir_path,
                                                   allow_directories=True)

            items_to_stage = 0
            for index, dir_item in enumerate(dir_items):
                # Get name of show and skip if blocked
                tvshow_label = dir_item['label']
                if self.dbh.check_blocked(tvshow_label, 'tvshow'):
                    continue
                # Update progress
                percent = 100 * index / len(dir_items)
                p_dialog.update(percent,
                                line1=(STR_GETTING_ITEMS_IN_x % tvshow_label))
                # Get everything inside tvshow path
                tvshow_path = dir_item['file']
                show_items = utils.load_directory_items(tvshow_path,
                                                        recursive=True)
                # Get all items to stage in show
                for show_item in show_items:
                    # Check for duplicate paths and blocked items
                    if self.dbh.path_exists(
                            show_item['file']) or self.dbh.check_blocked(
                                show_item['label'], 'episode'):
                        continue
                    # Update progress
                    p_dialog.update(percent, line2=show_item['label'])
                    self.dbh.add_content_item(show_item['file'],
                                              show_item['label'], 'tvshow',
                                              tvshow_label)
                    items_to_stage += 1
                    p_dialog.update(percent, line2=' ')
                p_dialog.update(percent, line1=' ')
            utils.notification(STR_i_EPISODES_STAGED % items_to_stage)
        finally:
            p_dialog.close()
예제 #20
0
 def remove_all_episodes(self, show_title):
     ''' Remove all episodes from the specified show '''
     STR_REMOVING_ALL_x_EPISODES = utils.getlocalizedstring(
         32032) % show_title
     STR_ALL_x_EPISODES_REMOVED = utils.getlocalizedstring(
         32033) % show_title
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_x_EPISODES)
     self.dbh.remove_from(status='staged',
                          mediatype='tvshow',
                          show_title=show_title,
                          directory=None)
     progress_dialog.close()
     utils.notification(STR_ALL_x_EPISODES_REMOVED)
예제 #21
0
 def remove_episodes(items):
     ''' Remove all episodes in specified show from library '''
     STR_REMOVING_ALL_x_EPISODES = utils.ADDON.getLocalizedString(32032)
     STR_ALL_x_EPISODES_REMOVED = utils.ADDON.getLocalizedString(32033)
     show_title = items[0].show_title
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME,
                            STR_REMOVING_ALL_x_EPISODES % show_title)
     for index, item in enumerate(items):
         percent = 100 * index / len(items)
         progress_dialog.update(percent, line2=item.title)
         item.remove_from_library()
         item.delete()
     progress_dialog.close()
     utils.notification(STR_ALL_x_EPISODES_REMOVED % show_title)
 def rename_episodes_using_metadata(items):
     ''' Rename all episodes in show using nfo files '''
     STR_RENAMING_x_EPISODES_USING_METADATA = utils.ADDON.getLocalizedString(32075)
     STR_x_EPISODES_RENAMED_USING_METADATA = utils.ADDON.getLocalizedString(32076)
     show_title = items[0].show_title
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(
         utils.ADDON_NAME, STR_RENAMING_x_EPISODES_USING_METADATA % show_title
     )
     for index, item in enumerate(items):
         percent = 100 * index / len(items)
         progress_dialog.update(percent, line2=item.title)
         item.rename_using_metadata()
     progress_dialog.close()
     utils.notification(STR_x_EPISODES_RENAMED_USING_METADATA % show_title)
 def read_all_metadata(self):
     ''' Read metadata for all staged tvshow items '''
     STR_READING_ALL_TV_SHOW_METADATA = utils.ADDON.getLocalizedString(32145)
     STR_ALL_TV_SHOW_METADATA_READ = utils.ADDON.getLocalizedString(32146)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_READING_ALL_TV_SHOW_METADATA)
     staged_tv_items = self.dbh.get_content_items(
         status='staged', mediatype='tvshow', order='Show_Title'
     )
     for index, item in enumerate(staged_tv_items):
         percent = 100 * index / len(staged_tv_items)
         progress_dialog.update(percent, line2=item.show_title, line3=item.title)
         item.read_metadata_item()
     progress_dialog.close()
     utils.notification(STR_ALL_TV_SHOW_METADATA_READ)
 def clean_up_metadata():
     ''' Remove all unused metadata '''
     STR_MOVIE_METADATA_CLEANED = utils.ADDON.getLocalizedString(32136)
     metadata_dir = os.path.join(utils.METADATA_FOLDER, 'Movies')
     for folder in os.listdir(metadata_dir):
         full_path = os.path.join(metadata_dir, folder)
         if os.path.isdir(full_path):
             folder_contents = os.listdir(full_path)
             if len(folder_contents) == 1 and fnmatch(
                     folder_contents[0], '*.strm'):
                 utils.log_msg(
                     'Removing metadata folder {}'.format(full_path),
                     loglevel=xbmc.LOGNOTICE)
             shutil.rmtree(full_path)
     utils.notification(STR_MOVIE_METADATA_CLEANED)
 def add_all_shows(self):
     ''' Add all tvshow items to library '''
     STR_ADDING_ALL_TV_SHOWS = utils.ADDON.getLocalizedString(32059)
     STR_ALL_TV_SHOWS_ADDED = utils.ADDON.getLocalizedString(32060)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_ADDING_ALL_TV_SHOWS)
     staged_tv_items = self.dbh.get_content_items(
         status='staged', mediatype='tvshow', order='Show_Title'
     )
     for index, item in enumerate(staged_tv_items):
         percent = 100 * index / len(staged_tv_items)
         progress_dialog.update(percent, line2=item.title)
         item.add_to_library()
     progress_dialog.close()
     utils.notification(STR_ALL_TV_SHOWS_ADDED)
def main():
    ''' Main entrypoint for context menu item '''
    # is more simple and fast ask user about type, many addons don't give this info
    label = sys.listitem.getLabel()  # pylint: disable=E1101
    year = xbmc.getInfoLabel('ListItem.Year')
    # if year is False, load load_directory_items will use json year
    year = int(year) if year != '' else False
    selected_path = sys.listitem.getPath() # pylint: disable=E1101
    STR_FORMED_TYPE_OF_CONTENT = '%s - %s' % (
        utils.title_with_color(label=label, year=year), STR_CHOOSE_CONTENT_TYPE)
    # Using the Dialog().select method is better as
    # it allows the user to cancel if they want,
    # and we can add more options if needed.
    lines = [
        STR_IS_A_MOVIE,
        STR_IS_A_SHOW,
        STR_CANCEL_RED
    ]
    # I tried to add as many checks to determine the type,
    # maybe the dialog can be removed, but I prefer mater
    typeofcontent = xbmcgui.Dialog().select(
        STR_FORMED_TYPE_OF_CONTENT, lines
        )
    selection = lines[typeofcontent]
    if selection:
        # Call corresponding method
        if (selection == STR_IS_A_MOVIE and
                utils.re_search(selected_path, LIST_TYPE_MOVIES)):
            SyncedMenu().sync_single_movie(
                title=label,
                year=year,
                link_stream_path=selected_path
                )
        elif (selection == STR_IS_A_SHOW and
              utils.re_search(selected_path, LIST_TYPE_SERIES)):
            SyncedMenu().sync_single_tvshow(
                title=label,
                year=year,
                link_stream_path=selected_path
                )
        elif selection == STR_CANCEL_RED:
            xbmc.sleep(200)
            utils.notification(utils.getlocalizedstring(32158))
        else:
            utils.notification('%s %s' % (utils.title_with_color(
                label=label,
                year=year), STR_NOT_SELECTED))
예제 #27
0
    def add_all_with_metadata(items):
        ''' Add all movies with nfo files to the library '''
        # TODO: Remove code duplication with MovieItem.add_to_library_if_metadata
        STR_ADDING_ALL_MOVIES_WITH_METADATA = utils.getlocalizedstring(32044)
        STR_ALL_MOVIES_WITH_METADTA_ADDED = utils.getlocalizedstring(32045)

        progress_dialog = xbmcgui.DialogProgress()
        progress_dialog.create(utils.ADDON_NAME,
                               STR_ADDING_ALL_MOVIES_WITH_METADATA)

        for index, item in enumerate(items):
            percent = 100 * index / len(items)
            if os.path.exists(item.movie_nfo[0]):
                progress_dialog.update(int(percent), item.movie_title)
                item.add_to_library()
        progress_dialog.close()
        utils.notification(STR_ALL_MOVIES_WITH_METADTA_ADDED)
예제 #28
0
 def generate_all_metadata(self):
     ''' Create metadata for all staged tvshow items '''
     STR_GENERATING_ALL_TV_SHOW_METADATA = utils.getlocalizedstring(32063)
     STR_ALL_TV_SHOW_METADATA_CREATED = utils.getlocalizedstring(32064)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME,
                            STR_GENERATING_ALL_TV_SHOW_METADATA)
     staged_tv_items = self.dbh.get_content_items(status='staged',
                                                  mediatype='tvshow',
                                                  order='Show_Title')
     for index, item in enumerate(staged_tv_items):
         percent = 100 * index / len(staged_tv_items)
         progress_dialog.update(percent, line2=item.show_title)
         xbmc.sleep(200)
         item.create_metadata_item()
     progress_dialog.close()
     utils.notification(STR_ALL_TV_SHOW_METADATA_CREATED)
예제 #29
0
 def remove_all(self):
     ''' Remove all managed tvshow items from library '''
     STR_REMOVING_ALL_TV_SHOWS = utils.ADDON.getLocalizedString(32024)
     STR_ALL_TV_SHOWS_REMOVED = utils.ADDON.getLocalizedString(32025)
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(utils.ADDON_NAME, STR_REMOVING_ALL_TV_SHOWS)
     managed_tv_items = self.dbh.get_content_items(status='managed',
                                                   mediatype='tvshow',
                                                   order='Show_Title')
     for index, item in enumerate(managed_tv_items):
         percent = 100 * index / len(managed_tv_items)
         progress_dialog.update(percent,
                                line2=item.show_title,
                                line3=item.title)
         item.remove_from_library()
         item.delete()
     progress_dialog.close()
     utils.notification(STR_ALL_TV_SHOWS_REMOVED)
예제 #30
0
 def move_episodes_to_staged(items):
     ''' Remove all managed episodes in specified show from library, and add them to staged '''
     STR_MOVING_ALL_x_EPISODES_BACK_TO_STAGED = utils.ADDON.getLocalizedString(
         32034)
     STR_ALL_x_EPISODES_MOVED_TO_STAGED = utils.ADDON.getLocalizedString(
         32035)
     show_title = items[0].show_title
     progress_dialog = xbmcgui.DialogProgress()
     progress_dialog.create(
         utils.ADDON_NAME,
         STR_MOVING_ALL_x_EPISODES_BACK_TO_STAGED % show_title)
     for index, item in enumerate(items):
         percent = 100 * index / len(items)
         progress_dialog.update(percent, line2=item.title)
         item.remove_from_library()
         item.set_as_staged()
     progress_dialog.close()
     utils.notification(STR_ALL_x_EPISODES_MOVED_TO_STAGED % show_title)