Esempio n. 1
0
    def run(self, force_run):
        log.info("Checking version")

        # Wait for internet connection
        utils.wait_for_internet_connection()

        # Block version check (and update) in no force run mode when another process is using the wanted queue
        # We do not want to auto update the version while the application is busy with another process
        if not force_run and not utils.get_wanted_queue_lock():
            return False

        # Check version
        self.manager.check_version(force_run)

        # Release wanted queue lock
        if not force_run:
            utils.release_wanted_queue_lock()

        # Only update and restart when: no force run, update is allowed and auto update is enabled
        if not force_run and self.manager.update_allowed and autosubliminal.CHECKVERSIONAUTOUPDATE:
            self.update()
            # Restart the app with exit of current process to have a clean restart
            scheduler.restart_app(exit=True)

        # Always return 'True' because we don't want to retry it until the next scheduled run
        return True
Esempio n. 2
0
    def run(self, force_run):
        log.info("Checking version")

        # Wait for internet connection
        utils.wait_for_internet_connection()

        # Block version check (and update) in no force run mode when another process is using the wanted queue
        # We do not want to auto update the version while the application is busy with another process
        if not force_run and not utils.get_wanted_queue_lock():
            return False

        # Check version
        self.manager.check_version(force_run)

        # Release wanted queue lock
        if not force_run:
            utils.release_wanted_queue_lock()

        # Only update and restart when: no force run, update is allowed and auto update is enabled
        if not force_run and self.manager.update_allowed and autosubliminal.CHECKVERSIONAUTOUPDATE:
            self.update()
            # Restart the app with exit of current process to have a clean restart
            scheduler.restart_app(exit=True)

        # Always return 'True' because we don't want to retry it until the next scheduled run
        return True
Esempio n. 3
0
    def run(self, force_run):
        log.info("Starting round of subtitle checking")
        to_delete_wanted_queue = []

        # Wait for internet connection
        utils.wait_for_internet_connection()

        # Get wanted queue lock
        if not utils.get_wanted_queue_lock():
            return False

        # Show info message (only when run was forced manually)
        if force_run:
            utils.add_notification_message("Checking subtitles...")

        # Process all items in wanted queue
        for index, wanted_item in enumerate(autosubliminal.WANTEDQUEUE):
            # Scan wanted_item for video, skip when no video could be determined
            video = _scan_wanted_item_for_video(wanted_item)
            if not video:
                continue

            # Check subtitles for each language
            langs = wanted_item['lang']
            for lang in langs[:]:
                # Search the best subtitle with the minimal score
                subtitles, language, single = _search_subtitles(
                    video, lang, True)

                # Save when a subtitle is found for the video
                if subtitles[video]:
                    download_item = _construct_download_item(
                        wanted_item, subtitles, language, single)
                    SubDownloader(download_item).run()

                    # Remove from wanted queue if needed (if no additional languages are still needed)
                    langs.remove(lang)
                    if len(langs) == 0:
                        to_delete_wanted_queue.append(index)

        # Cleanup wanted queue
        i = len(to_delete_wanted_queue) - 1
        while i >= 0:
            log.debug("Removed item from the wanted queue at index %s" %
                      to_delete_wanted_queue[i])
            autosubliminal.WANTEDQUEUE.pop(to_delete_wanted_queue[i])
            i -= 1

        # Release wanted queue lock
        log.info("Finished round of subtitle checking")
        utils.release_wanted_queue_lock()

        return True
Esempio n. 4
0
    def run(self, force_run):
        log.info("Starting round of subtitle checking")
        to_delete_wanted_queue = []

        # Wait for internet connection
        utils.wait_for_internet_connection()

        # Get wanted queue lock
        if not utils.get_wanted_queue_lock():
            return False

        # Show info message (only when run was forced manually)
        if force_run:
            utils.add_notification_message("Checking subtitles...")

        # Process all items in wanted queue
        for index, wanted_item in enumerate(autosubliminal.WANTEDQUEUE):
            # Scan wanted_item for video, skip when no video could be determined
            video = _scan_wanted_item_for_video(wanted_item)
            if not video:
                continue

            # Check subtitles for each language
            langs = wanted_item['lang']
            for lang in langs[:]:
                # Search the best subtitle with the minimal score
                subtitles, language, single = _search_subtitles(video, lang, True)

                # Save when a subtitle is found for the video
                if subtitles[video]:
                    download_item = _construct_download_item(wanted_item, subtitles, language, single)
                    SubDownloader(download_item).run()

                    # Remove from wanted queue if needed (if no additional languages are still needed)
                    langs.remove(lang)
                    if len(langs) == 0:
                        to_delete_wanted_queue.append(index)

        # Cleanup wanted queue
        i = len(to_delete_wanted_queue) - 1
        while i >= 0:
            log.debug("Removed item from the wanted queue at index %s" % to_delete_wanted_queue[i])
            autosubliminal.WANTEDQUEUE.pop(to_delete_wanted_queue[i])
            i -= 1

        # Release wanted queue lock
        log.info("Finished round of subtitle checking")
        utils.release_wanted_queue_lock()

        return True
Esempio n. 5
0
    def run(self, force_run):
        # Get wanted queue lock
        if not utils.get_wanted_queue_lock():
            return False

        # Wait for internet connection
        utils.wait_for_internet_connection()

        log.info('Starting round of subtitle checking')
        to_delete_wanted_queue = []

        # Show info message (only when run was forced manually)
        if force_run:
            utils.add_notification_message('Checking subtitles...')

        # Setup provider pool
        provider_pool = _get_provider_pool()
        if provider_pool:
            log.info('Searching subtitles with providers: %s',
                     ', '.join(provider_pool.providers))

            # Process all items in wanted queue
            db = WantedItems()
            for index, wanted_item in enumerate(autosubliminal.WANTEDQUEUE):
                log.info('Searching subtitles for video: %s',
                         wanted_item['videopath'])

                # Check if the search is currently active for the wanted_item
                if not WantedItem(wanted_item).search_active:
                    log.info('Search not active in this run for video: %s',
                             wanted_item['videopath'])
                    continue

                # Scan wanted_item for video, skip when no video could be determined
                video = _scan_wanted_item_for_video(wanted_item)
                if not video:
                    continue

                # Clear discarded providers for each new wanted_item
                provider_pool.discarded_providers.clear()

                # Check subtitles for each language
                languages = wanted_item['languages']
                for lang in languages[:]:
                    # Search the best subtitle with the minimal score
                    try:
                        subtitles, language, single = _search_subtitles(
                            video, lang, True, provider_pool)
                    except Exception:
                        log.exception(
                            'Error while searching subtitles for video %r',
                            wanted_item['videopath'])
                        continue

                    # Subtitle is found for the video
                    if subtitles:
                        # Handle download
                        download_item = _construct_download_item(
                            wanted_item, subtitles, language, single)
                        SubDownloader(download_item).run()

                        # Remove downloaded language from wanted languages
                        languages.remove(lang)

                        # Update wanted item if there are still wanted languages
                        if len(languages) > 0:
                            db.update_wanted_item(wanted_item)

                        # Mark wanted item as deleted if there are no more wanted languages
                        else:
                            to_delete_wanted_queue.append(index)

            # Cleanup wanted item(s)
            i = len(to_delete_wanted_queue) - 1
            while i >= 0:
                wanted_item_to_delete = autosubliminal.WANTEDQUEUE.pop(
                    to_delete_wanted_queue[i])
                log.debug('Removed item from the wanted queue at index %s',
                          to_delete_wanted_queue[i])
                db.delete_wanted_item(wanted_item_to_delete)
                log.debug('Removed %s from wanted_items database',
                          wanted_item_to_delete['videopath'])
                i -= 1

        else:
            log.info('No subliminal providers configured, skipping')

        # Release wanted queue lock
        log.info('Finished round of subtitle checking')
        utils.release_wanted_queue_lock()

        # Send home page reload event
        utils.add_event_message('HOME_PAGE_RELOAD')

        return True