示例#1
0
def post_process_no_subtitle(wanted_item_index):
    log.info('Post processing without subtitle')

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

    # Get wanted item
    wanted_item = autosubliminal.WANTEDQUEUE[int(wanted_item_index)]

    # Post process only (no need to check for individual or not because we are forcing post processing)
    processed = PostProcessor(wanted_item).run()

    # Remove wanted item if processed
    if processed:
        autosubliminal.WANTEDQUEUE.pop(int(wanted_item_index))
        log.debug('Removed item from the wanted queue at index %s',
                  int(wanted_item_index))
        WantedItems().delete_wanted_item(wanted_item)
        log.debug('Removed %s from wanted_items database',
                  wanted_item['videopath'])
    else:
        utils.add_notification_message(
            'Unable to handle post processing! Please check the log file!',
            'error')

    # Release wanted queue lock
    utils.release_wanted_queue_lock()

    return processed
示例#2
0
    def run(self, force_run):
        log.info("Starting round of local disk checking at %s" % autosubliminal.VIDEOPATHS)

        # 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("Scanning disk...")

        # Check if a directory exists to scan
        one_dir_exists = False
        for videodir in autosubliminal.VIDEOPATHS:
            if os.path.exists(videodir):
                one_dir_exists = True
            else:
                # In case of a network path, it's possible that the path is not directly found -> sleep and check again
                time.sleep(15)
                if os.path.exists(videodir):
                    one_dir_exists = True
        if not one_dir_exists:
            # Release wanted queue lock
            log.error("None of the configured video paths (%s) exist, aborting..." % autosubliminal.VIDEOPATHS)
            utils.release_wanted_queue_lock()
            return True

        # Reset the wanted queue before walking through paths and adding the wanted items
        autosubliminal.WANTEDQUEUE = []
        for videodir in autosubliminal.VIDEOPATHS:
            try:
                walk_dir(videodir)
            except Exception, e:
                log.error("Could not scan the video path (%s), skipping..." % videodir)
                log.exception(e)
示例#3
0
    def run(self):
        """
        Save the subtitle with further handling
        """

        log.info('Running sub downloader')

        # Save the subtitle
        if self.save():
            name = utils.display_name(self._download_item)

            # Mark as downloaded
            self.mark_downloaded()

            # Post process
            processed = self.post_process()
            if not processed:
                utils.add_notification_message(
                    'Unable to handle post processing for \'%s\'! Please check the log file!'
                    % name, 'error')

            # Show success message
            language = self._download_item['downlang']
            name = utils.display_name(self._download_item)
            provider = self._download_item['provider']
            utils.add_notification_message(
                'Downloaded \'%s\' subtitle for \'%s\' from \'%s\'.' %
                (language, name, provider), 'success')
示例#4
0
 def update_version(self):
     if self.update_allowed:
         try:
             self.repo.remote(name='origin').pull()
             log.info("Updated to the latest version")
             utils.add_notification_message("Updated to the latest version")
         except:
             log.error("Could not update version: %s" % traceback.format_exc())
示例#5
0
 def test(self, notify_lib):
     if notifiers.test_notifier(notify_lib):
         utils.add_notification_message("Test notification (%s) sent" %
                                        notify_lib)
     else:
         utils.add_notification_message(
             "Test notification (%s) failed" % notify_lib, "error")
     redirect("/config/notification")
示例#6
0
 def update_version(self):
     if self.update_allowed:
         try:
             self.repo.remote(name='origin').pull()
             log.info("Updated to the latest version")
             utils.add_notification_message("Updated to the latest version")
         except:
             log.error("Could not update version: %s" %
                       traceback.format_exc())
示例#7
0
 def test(self, notify_lib):
     if notifiers.test_notifier(notify_lib):
         utils.add_notification_message('Test notification (%s) sent.' %
                                        notify_lib)
     else:
         utils.add_notification_message(
             'Test notification (%s) failed! Please check the log file!'
             % notify_lib, 'error')
     return {}
示例#8
0
 def update_version(self):
     if self.update_allowed:
         try:
             # Do a git clean before and after the update to remove all untracked files
             self.clean()
             self.repo.remote(name='origin').pull()
             self.clean()
             log.info('Updated to the latest version')
             utils.add_notification_message('Updated to the latest version.')
         except Exception:
             log.exception('Could not update version')
示例#9
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
示例#10
0
 def run_now(self):
     # Run threads now (use delay to be sure that checksub is run after scandisk)
     autosubliminal.SCANDISK.run()
     autosubliminal.CHECKSUB.run(delay=0.5)
     useragent = cherrypy.request.headers.get("User-Agent", '')
     if autosubliminal.MOBILE and utils.check_mobile_device(useragent):
         tmpl = Template(file="interface/templates/mobile/message.tmpl")
         tmpl.message = "Running everything <br> <a href='" + autosubliminal.WEBROOT + "/home'>Return</a>"
         return str(tmpl)
     else:
         utils.add_notification_message("Running everything...")
         redirect("/home")
示例#11
0
 def run_now(self):
     # Run threads now (use delay to be sure that checksub is run after scandisk)
     autosubliminal.SCANDISK.run()
     autosubliminal.CHECKSUB.run(delay=0.5)
     useragent = cherrypy.request.headers.get("User-Agent", '')
     if autosubliminal.MOBILE and utils.check_mobile_device(useragent):
         tmpl = Template(file="interface/templates/mobile/message.tmpl")
         tmpl.message = "Running everything <br> <a href='" + autosubliminal.WEBROOT + "/home'>Return</a>"
         return str(tmpl)
     else:
         utils.add_notification_message("Running everything...")
         redirect("/home")
示例#12
0
    def save_and_restart_if_needed(section=None):
        # Save to the configfile
        restart = config.write_config(section)

        # Check if restart is needed
        if restart:
            return {'restart': True}

        else:
            # For some reason the config needs to be read again, otherwise all pages get an error
            config.read_config()
            utils.add_notification_message('Config saved.')
            return {}
示例#13
0
 def flush_wanted_items(self):
     if utils.get_wanted_queue_lock():
         # Flush db and wanted queue
         WantedItems().flush_wanted_items()
         autosubliminal.WANTEDQUEUE = []
         utils.release_wanted_queue_lock()
         utils.add_notification_message(
             'Flushed wanted items database. Please launch system \'Scan Disk\'.'
         )
     else:
         utils.add_notification_message(
             'Cannot flush wanted items database when wanted queue is in use!',
             'notice')
     redirect('/home')
示例#14
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
示例#15
0
    def save_and_restart_if_needed(return_tmpl_file):
        # Save to the configfile
        restart = config.write_config()

        # Check if restart is needed
        if restart:
            # Restart the runner in the background
            scheduler.restart_app()
            tmpl = Template(file="interface/templates/system/restart.tmpl")
            tmpl.message = "Saved config. Auto restart in progress..."
            return str(tmpl)

        else:
            # For some reason the config needs to be read again, otherwise all pages get an error
            config.read_config()
            utils.add_notification_message("Config saved")
            redirect_referer("/config")
示例#16
0
    def save_and_restart_if_needed(return_tmpl_file):
        # Save to the configfile
        restart = config.write_config()

        # Check if restart is needed
        if restart:
            # Restart the runner in the background
            scheduler.restart_app()
            tmpl = Template(file="interface/templates/system/restart.tmpl")
            tmpl.message = "Saved config. Auto restart in progress..."
            return str(tmpl)

        else:
            # For some reason the config needs to be read again, otherwise all pages get an error
            config.read_config()
            utils.add_notification_message("Config saved")
            redirect_referer("/config")
示例#17
0
 def delete_video(self, wanted_item_index, confirmed=False, cleanup=False):
     if not confirmed:
         wanted_item = autosubliminal.WANTEDQUEUE[int(wanted_item_index)]
         video = wanted_item['videopath']
         return PageTemplate(filename='/home/home-deleteVideo.mako').render(
             wanted_item_index=wanted_item_index, video=video)
     else:
         # Delete video
         deleted = subchecker.delete_video(wanted_item_index, cleanup)
         if deleted:
             utils.add_notification_message(
                 'Video deleted from filesystem.')
         else:
             utils.add_notification_message(
                 'Video could not be deleted! Please check the log file!',
                 'error')
         redirect('/home')
示例#18
0
    def run(self):
        """
        Save the subtitle with further handling
        """

        log.info("Running sub downloader")

        # Check download_item
        if 'video' in self._keys and 'subtitles' in self._keys and 'single' in self._keys:

            # Save the subtitle
            video = self._download_item['video']
            subliminal.save_subtitles(video,
                                      self._download_item['subtitles'][video],
                                      self._download_item['single'])

            # Add download_item to last downloads
            self._download_item['timestamp'] = time.strftime(
                '%Y-%m-%d %H:%M:%S')
            LastDownloads().set_last_downloads(self._download_item)

            # Notify
            if autosubliminal.NOTIFY:
                Notifier(self._download_item).notify_download()

            # Post processing
            if autosubliminal.POSTPROCESS:
                PostProcessor(self._download_item).run()

            # Show success message
            language = self._download_item['downlang']
            name = utils.display_name(self._download_item)
            provider = self._download_item['provider']
            utils.add_notification_message(
                "Downloaded '" + language + "' subtitle for '" + name +
                "' from '" + provider + "'", 'success')

            return True
        else:
            log.error("Download item is not complete, skipping")
            return False
示例#19
0
    def run(self, force_run):
        log.info("Starting round of local disk checking at %s" %
                 autosubliminal.VIDEOPATHS)

        # 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("Scanning disk...")

        # Check if a directory exists to scan
        one_dir_exists = False
        for videodir in autosubliminal.VIDEOPATHS:
            if os.path.exists(videodir):
                one_dir_exists = True
            else:
                # In case of a network path, it's possible that the path is not directly found -> sleep and check again
                time.sleep(15)
                if os.path.exists(videodir):
                    one_dir_exists = True
        if not one_dir_exists:
            # Release wanted queue lock
            log.error(
                "None of the configured video paths (%s) exist, aborting..." %
                autosubliminal.VIDEOPATHS)
            utils.release_wanted_queue_lock()
            return True

        # Reset the wanted queue before walking through paths and adding the wanted items
        autosubliminal.WANTEDQUEUE = []
        for videodir in autosubliminal.VIDEOPATHS:
            try:
                walk_dir(videodir)
            except Exception, e:
                log.error("Could not scan the video path (%s), skipping..." %
                          videodir)
                log.exception(e)
示例#20
0
    def run(self):
        """
        Save the subtitle with further handling
        """

        log.info("Running sub downloader")

        # Check download_item
        if 'video' in self._keys and 'subtitles' in self._keys and 'single' in self._keys:

            # Save the subtitle
            video = self._download_item['video']
            subliminal.save_subtitles(video, self._download_item['subtitles'][video], self._download_item['single'])

            # Add download_item to last downloads
            self._download_item['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S')
            LastDownloads().set_last_downloads(self._download_item)

            # Notify
            if autosubliminal.NOTIFY:
                Notifier(self._download_item).notify_download()

            # Post processing
            if autosubliminal.POSTPROCESS:
                PostProcessor(self._download_item).run()

            # Show success message
            language = self._download_item['downlang']
            name = utils.display_name(self._download_item)
            provider = self._download_item['provider']
            utils.add_notification_message(
                "Downloaded '" + language + "' subtitle for '" + name + "' from '" + provider + "'", 'success')

            return True
        else:
            log.error("Download item is not complete, skipping")
            return False
示例#21
0
    def check_version(self, force_run=False):
        # Reset update_allowed flag
        self.update_allowed = False

        # Local git version
        log.debug("Local branch: %s" % self.current_git_branch)
        log.debug("Local commit: %s" % self.current_git_commit)
        if self.repo.is_dirty():
            log.warning("Local branch is dirty")

        # Remote git version
        try:
            remote_url = self.repo.remote(name='origin').url
            remote_fetch_info = self.repo.remote().fetch(refspec=self.current_git_branch)[0]
            remote_commit = remote_fetch_info.commit
            log.debug("Remote url: %s" % remote_url)
            log.debug("Remote commit: %s" % remote_commit)
        except:
            log.error("Could not get remote git version")
            return False

        # Get number of commits ahead and behind (option --count not supported git < 1.7.2)
        try:
            ahead, behind = self.repo.git.execute('git rev-list --count --left-right HEAD...@{upstream}').split('\t')
            self.num_commits_ahead = int(ahead)
            self.num_commits_behind = int(behind)
        except:
            # Count it ourselves when option --count is not supported
            try:
                output = self.repo.git.execute('git rev-list --left-right HEAD...@{upstream}')
                self.num_commits_ahead = int(output.count('<'))
                self.num_commits_behind = int(output.count('>'))
            except:
                log.error("Could not get the difference in commits between local and remote branch")
                return False
        log.debug("Number of commits ahead: %s" % self.num_commits_ahead)
        log.debug("Number of commits behind: %s" % self.num_commits_behind)

        if self.num_commits_ahead > 0:
            log.info("Unknown version found")
            utils.add_notification_message(
                "Unknown version found! Check <a href=" + autosubliminal.GITHUBURL +
                "/releases>Github</a> and reinstall!", "error", True)
        elif self.num_commits_behind > 0:
            log.info("New version found")
            utils.add_notification_message(
                "New version found! <a href=" + autosubliminal.WEBROOT + "/system/updateVersion>Update</a>",
                "notice", True)
            self.update_allowed = True
        else:
            log.info("Version up to date")
            # Show info message (only when run was forced manually)
            if force_run:
                utils.add_notification_message("You are running the latest version")

        return True
示例#22
0
    def check_version(self, force_run=False):
        # Reset update_allowed flag
        self.update_allowed = False

        # Local git version
        log.debug('Local branch: %s', self.current_git_branch)
        log.debug('Local commit: %s', self.current_git_commit)
        if self.repo.is_dirty():
            log.warning('Local branch is dirty')

        # Remote git version
        try:
            remote_url = self.repo.remote(name='origin').url
            remote_fetch_info = self.repo.remote().fetch(refspec=self.current_git_branch)[0]
            remote_commit = remote_fetch_info.commit
            log.debug('Remote url: %s', remote_url)
            log.debug('Remote commit: %s', remote_commit)
        except Exception:
            log.exception('Could not get remote git version')
            return False

        # Get number of commits ahead and behind (option --count not supported git < 1.7.2)
        try:
            ahead, behind = self.repo.git.execute('git rev-list --count --left-right HEAD...@{upstream}').split('\t')
            self.num_commits_ahead = int(ahead)
            self.num_commits_behind = int(behind)
        except Exception:
            # Count it ourselves when option --count is not supported
            try:
                output = self.repo.git.execute('git rev-list --left-right HEAD...@{upstream}')
                self.num_commits_ahead = int(output.count('<'))
                self.num_commits_behind = int(output.count('>'))
            except Exception:
                log.exception('Could not get the difference in commits between local and remote branch')
                return False
        log.debug('Number of commits ahead: %s', self.num_commits_ahead)
        log.debug('Number of commits behind: %s', self.num_commits_behind)

        if self.num_commits_ahead > 0:
            log.info('Unknown version found')
            utils.add_notification_message(
                'Unknown version found! Check <a href=' + autosubliminal.GITHUBURL +
                '/releases>Github</a> and reinstall!', 'error', True)
        elif self.num_commits_behind > 0:
            log.info('New version found')
            utils.add_notification_message(
                'New version found. <a href=' + autosubliminal.WEBROOT + '/system/updateVersion>Update</a>!',
                'notice', True)
            self.update_allowed = True
        else:
            log.info('Version up to date')
            # Show info message (only when run was forced manually)
            if force_run:
                utils.add_notification_message('You are running the latest version.')

        return True
示例#23
0
    def skip_show(self, wanted_item_index, title, season=None):
        if not season:
            return PageTemplate(filename='/home/home-skipshow.mako').render(
                wanted_item_index=wanted_item_index, title=title)
        else:
            if not wanted_item_index:
                raise cherrypy.HTTPError(400, 'No wanted_item index supplied')
            if not title:
                raise cherrypy.HTTPError(400, 'No show supplied')
            # Check if season is a number to be sure
            if not season == '00':
                season = text_type(int(season))
            config_season = season
            # Check if already skipped
            title_sanitized = utils.sanitize(title)
            for x in autosubliminal.SKIPSHOW:
                if title_sanitized == utils.sanitize(x):
                    for s in autosubliminal.SKIPSHOW[x].split(','):
                        if s == season or s == '00':
                            utils.add_notification_message(
                                'Already skipped show %s season %s.' %
                                (title, season))
                            redirect('/home')
                    # Not skipped yet, skip all or append season the seasons to skip
                    if season == '00':
                        config_season = '00'
                    else:
                        seasons = autosubliminal.SKIPSHOW[x].split(',')
                        seasons.append(season)
                        config_season = ','.join(sorted(seasons))
            # Skip show
            if subchecker.skip_show(wanted_item_index, season):
                config.write_config_property('skipshow', title, config_season)
                config.apply_skipshow()
                if season == '00':
                    utils.add_notification_message(
                        'Skipped show %s all seasons.' % title)
                else:
                    utils.add_notification_message(
                        'Skipped show %s season %s.' % (title, season))
            else:
                utils.add_notification_message(
                    'Could not skip show! Please check the log file!', 'error')

            redirect('/home')
示例#24
0
    def check_version(self, force_run=False):
        # Reset update_allowed flag
        self.update_allowed = False

        # Local version
        local_version = self.current_strict_version
        log.debug("Local version: %s" % local_version)

        # Remote github version
        try:
            req = urllib2.Request(autosubliminal.VERSIONURL)
            req.add_header("User-agent", autosubliminal.USERAGENT)
            resp = urllib2.urlopen(req, None, autosubliminal.TIMEOUT)
            response = resp.read()
            resp.close()
        except:
            log.error("Could not get remote version from %s" %
                      autosubliminal.VERSIONURL)
            return False
        try:
            match = re.search('(\d+)\.(\d+)\.(\d+)', response)
            remote_version = version.StrictVersion(match.group(0))
            log.debug("Remote version: %s" % remote_version)
        except:
            log.error("Could not parse version from %s" %
                      autosubliminal.VERSIONURL)
            return False

        # Compare versions
        if local_version > remote_version:
            log.info("Unknown version found")
            utils.add_notification_message(
                "Unknown version found! Check <a href=" +
                autosubliminal.GITHUBURL +
                "/releases>Github</a> and reinstall!", "error", True)
        elif local_version < remote_version:
            log.info("New version found")
            utils.add_notification_message(
                "New version found! Check <a href=" +
                autosubliminal.GITHUBURL + "/releases>Github</a> and update!",
                "notice", True)
        else:
            log.info("Version up to date")
            # Show info message (only when run was forced manually)
            if force_run:
                utils.add_notification_message(
                    "You are running the latest version")

        return True
示例#25
0
    def check_version(self, force_run=False):
        # Reset update_allowed flag
        self.update_allowed = False

        # Local version
        local_version = self.current_strict_version
        log.debug("Local version: %s" % local_version)

        # Remote github version
        try:
            req = urllib2.Request(autosubliminal.VERSIONURL)
            req.add_header("User-agent", autosubliminal.USERAGENT)
            resp = urllib2.urlopen(req, None, autosubliminal.TIMEOUT)
            response = resp.read()
            resp.close()
        except:
            log.error("Could not get remote version from %s" % autosubliminal.VERSIONURL)
            return False
        try:
            match = re.search('(\d+)\.(\d+)\.(\d+)', response)
            remote_version = version.StrictVersion(match.group(0))
            log.debug("Remote version: %s" % remote_version)
        except:
            log.error("Could not parse version from %s" % autosubliminal.VERSIONURL)
            return False

        # Compare versions
        if local_version > remote_version:
            log.info("Unknown version found")
            utils.add_notification_message(
                "Unknown version found! Check <a href="
                + autosubliminal.GITHUBURL + "/releases>Github</a> and reinstall!",
                "error", True)
        elif local_version < remote_version:
            log.info("New version found")
            utils.add_notification_message(
                "New version found! Check <a href=" + autosubliminal.GITHUBURL + "/releases>Github</a> and update!",
                "notice", True)
        else:
            log.info("Version up to date")
            # Show info message (only when run was forced manually)
            if force_run:
                utils.add_notification_message("You are running the latest version")

        return True
示例#26
0
    def check_version(self, force_run=False):
        # Reset update_allowed flag
        self.update_allowed = False

        # Local version
        local_version = self.current_strict_version
        log.debug('Local version: %s', local_version)

        # Remote github version
        try:
            response = utils.connect_url(autosubliminal.VERSIONURL)
        except Exception:
            log.exception('Could not get remote version from %s', autosubliminal.VERSIONURL)
            return False
        try:
            match = re.search(VERSION_PATTERN, response.text, re.MULTILINE)
            remote_version = version.StrictVersion(match.group(1))
            log.debug('Remote version: %r', remote_version)
        except Exception:
            log.exception('Could not parse version from %s', autosubliminal.VERSIONURL)
            return False

        # Compare versions
        if local_version > remote_version:
            log.info('Unknown version found')
            utils.add_notification_message(
                'Unknown version found! '
                'Check <a href=' + autosubliminal.GITHUBURL + '/releases>Github</a> and reinstall!',
                'error', True)
        elif local_version < remote_version:
            log.info('New version found')
            utils.add_notification_message(
                'New version found. '
                'Check <a href=' + autosubliminal.GITHUBURL + '/releases>Github</a> and update!',
                'notice', True)
        else:
            log.info('Version up to date')
            # Show info message (only when run was forced manually)
            if force_run:
                utils.add_notification_message('You are running the latest version.')

        return True
示例#27
0
 def skip_movie(self, wanted_item_index, title, year):
     if not wanted_item_index:
         raise cherrypy.HTTPError(400, 'No wanted_item index supplied')
     if not title:
         raise cherrypy.HTTPError(400, 'No title supplied')
     movie = title
     if year:
         movie += ' (' + year + ')'
     # Check if already skipped
     movie_sanitized = utils.sanitize(movie)
     for x in autosubliminal.SKIPMOVIE:
         if movie_sanitized == utils.sanitize(x):
             utils.add_notification_message('Already skipped movie %s.' %
                                            movie)
             redirect('/home')
     # Skip movie
     if subchecker.skip_movie(wanted_item_index):
         config.write_config_property('skipmovie', movie, '00')
         config.apply_skipmovie()
         utils.add_notification_message('Skipped movie %s.' % movie)
     else:
         utils.add_notification_message(
             'Could not skip movie! Please check the log file!', 'error')
     redirect('/home')
示例#28
0
 def flush_last_downloads(self):
     LastDownloads().flush_last_downloads()
     utils.add_notification_message("Flushed last downloads database")
     redirect("/home")
示例#29
0
 def flush_cache(self):
     TvdbIdCache().flush_cache()
     ImdbIdCache().flush_cache()
     utils.add_notification_message("Flushed id cache database")
     redirect("/home")
示例#30
0
 def flush_cache(self):
     TvdbIdCache().flush_cache()
     ImdbIdCache().flush_cache()
     utils.add_notification_message("Flushed id cache database")
     redirect("/home")
示例#31
0
 def flush_last_downloads(self):
     LastDownloads().flush_last_downloads()
     utils.add_notification_message("Flushed last downloads database")
     redirect("/home")
示例#32
0
 def test(self, notify_lib):
     if notifiers.test_notifier(notify_lib):
         utils.add_notification_message("Test notification (%s) sent" % notify_lib)
     else:
         utils.add_notification_message("Test notification (%s) failed" % notify_lib, "error")
     redirect("/config/notification")
示例#33
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
示例#34
0
 def run_now(self):
     # Run threads now (use delay to be sure that checksub is run after scandisk)
     autosubliminal.SCANDISK.run()
     autosubliminal.CHECKSUB.run(delay=1)
     utils.add_notification_message('Running everything...')
     redirect('/home')
示例#35
0
    def run(self, force_run):
        # Get wanted queue lock
        if not utils.get_wanted_queue_lock():
            return False

        log.info('Starting round of local disk checking at %r',
                 autosubliminal.VIDEOPATHS)

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

        # Check if a directory exists to scan
        one_dir_exists = False
        for videodir in autosubliminal.VIDEOPATHS:
            if os.path.exists(videodir):
                one_dir_exists = True
            else:
                # In case of a network path, it's possible that the path is not directly found -> sleep and check again
                time.sleep(15)
                if os.path.exists(videodir):
                    one_dir_exists = True
        if not one_dir_exists:
            # Release wanted queue lock
            log.error(
                'None of the configured video paths (%r) exists, aborting...',
                autosubliminal.VIDEOPATHS)
            utils.release_wanted_queue_lock()
            return True

        # Walk through paths to search for wanted items
        new_wanted_items = []
        db = WantedItems()
        old_wanted_items = db.get_wanted_items()
        for videodir in autosubliminal.VIDEOPATHS:
            try:
                new_wanted_items.extend(walk_dir(videodir))
            except Exception:
                log.exception(
                    'Could not scan the video path (%s), skipping it',
                    videodir)

        # Cleanup wanted items that have been removed from disk manually but are still stored in the db
        log.debug(
            'Checking for non existing wanted items in wanted_items database')
        for item in old_wanted_items:
            if item not in new_wanted_items:
                db.delete_wanted_item(item)
                log.debug('Deleted non existing wanted item: %s',
                          item['videopath'])

        # Populate WANTEDQUEUE with all items from wanted_items database
        log.info('Listing videos with missing subtitles:')
        autosubliminal.WANTEDQUEUE = []
        for item in db.get_wanted_items():
            log.info('%s %s', item['videopath'], item['languages'])
            autosubliminal.WANTEDQUEUE.append(item)

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

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

        return True