def _get_playing_show(self, filename): if not self.active: # Don't do anything if the Tracker is disabled return (STATE_NOVIDEO, None) if filename: if filename == self.last_filename: # It's the exact same filename, there's no need to do the processing again return (4, self.last_show_tuple) self.last_filename = filename # Do a regex to the filename to get # the show title and episode number aie = extras.AnimeInfoExtractor.AnimeInfoExtractor(filename) (show_title, show_ep) = (aie.getName(), aie.getEpisode()) if not show_title: return (STATE_UNRECOGNIZED, None) # Format not recognized playing_show = utils.guess_show(show_title, self.list) if playing_show: return (STATE_PLAYING, (playing_show, show_ep)) else: return (STATE_NOT_FOUND, None) # Show not in list else: self.last_filename = None return (STATE_NOVIDEO, None) # Not playing
def scan_library(self, my_status=None, ignorecache=False): # Check if operation is supported by the API if not self.mediainfo.get("can_play"): raise utils.EngineError("Operation not supported by current site or mediatype.") if not self.config["searchdir"]: raise utils.EngineError("Media directory is not set.") if not utils.dir_exists(self.config["searchdir"]): raise utils.EngineError("The set media directory doesn't exist.") t = time.time() library = {} library_cache = self.data_handler.library_cache_get() if not my_status: my_status = self.mediainfo["status_start"] self.msg.info(self.name, "Scanning local library...") tracker_list = self._get_tracker_list(my_status) # Do a full listing of the media directory for fullpath, filename in utils.regex_find_videos("mkv|mp4|avi", self.config["searchdir"]): show_id = None if not ignorecache and filename in library_cache.keys(): # If the filename was already seen before # use the cached information, if there's no information (None) # then it means it doesn't correspond to any show in the list # and can be safely skipped. if library_cache[filename]: show_id = library_cache[filename][0] show_ep = library_cache[filename][1] else: continue else: # If the filename has not been seen, extract # the information from the filename and do a fuzzy search # on the user's list. Cache the information. # If it fails, cache it as None. aie = extras.AnimeInfoExtractor.AnimeInfoExtractor(filename) (show_title, show_ep) = (aie.getName(), aie.getEpisode()) if show_title: show = utils.guess_show(show_title, tracker_list) if show: show_id = show["id"] library_cache[filename] = (show["id"], show_ep) else: library_cache[filename] = None else: library_cache[filename] = None # After we got our information, add it to our library if show_id: if show_id not in library.keys(): library[show_id] = {} library[show_id][show_ep] = fullpath self.msg.debug(self.name, "Time: %s" % (time.time() - t)) self.data_handler.library_save(library) self.data_handler.library_cache_save(library_cache) return library
def scan_library(self, my_status=None, ignorecache=False): # Check if operation is supported by the API if not self.mediainfo.get('can_play'): raise utils.EngineError( 'Operation not supported by current site or mediatype.') if not self.config['searchdir']: raise utils.EngineError('Media directory is not set.') if not utils.dir_exists(self.config['searchdir']): raise utils.EngineError('The set media directory doesn\'t exist.') t = time.time() library = {} library_cache = self.data_handler.library_cache_get() if not my_status: my_status = self.mediainfo['status_start'] self.msg.info(self.name, "Scanning local library...") tracker_list = self._get_tracker_list(my_status) # Do a full listing of the media directory for fullpath, filename in utils.regex_find_videos( 'mkv|mp4|avi', self.config['searchdir']): show_id = None if not ignorecache and filename in library_cache.keys(): # If the filename was already seen before # use the cached information, if there's no information (None) # then it means it doesn't correspond to any show in the list # and can be safely skipped. if library_cache[filename]: show_id = library_cache[filename][0] show_ep = library_cache[filename][1] else: continue else: # If the filename has not been seen, extract # the information from the filename and do a fuzzy search # on the user's list. Cache the information. # If it fails, cache it as None. aie = extras.AnimeInfoExtractor.AnimeInfoExtractor(filename) (show_title, show_ep) = (aie.getName(), aie.getEpisode()) if show_title: show = utils.guess_show(show_title, tracker_list) if show: show_id = show['id'] library_cache[filename] = (show['id'], show_ep) else: library_cache[filename] = None else: library_cache[filename] = None # After we got our information, add it to our library if show_id: if show_id not in library.keys(): library[show_id] = {} library[show_id][show_ep] = fullpath self.msg.debug(self.name, "Time: %s" % (time.time() - t)) self.data_handler.library_save(library) self.data_handler.library_cache_save(library_cache) return library