def add_torrent_magnet(self, filename: str) -> bool: """ adds a magnet link instead of the actual torrent file contents :param filename: like of where the file can be found or path to actual file :return: True if the operation was a success otherwise False """ try: torrent = self.client.torrent.add(filename=filename) sleep(.5) EventLogHelper.log_info( f"Added torrent file url to torrent client -> {torrent} | {filename}", self.__class__.__name__, inspect.currentframe().f_code.co_name) return True except Exception as e: EventLogHelper.log_warning( f"Unable to add torrent to transmission -> {e}", self.__class__.__name__, inspect.currentframe().f_code.co_name) return False
def add_torrent(self, file_path: str, file_name: str): """ adds the torrent from an existing file path :param file_name: name of the file :param file_path: where the file can be found :return: True if the operation was a success otherwise False """ try: file_contents = StorageUtil.read_file(file_path, file_name) torrent = self.client.torrent.add(metainfo=file_contents) sleep(1.5) EventLogHelper.log_info( f"Added torrent file to download client -> {torrent} | {file_path}", self.__class__.__name__, inspect.currentframe().f_code.co_name) return True except Exception as e: EventLogHelper.log_warning( f"Unable to add torrent to transmission -> {e}", self.__class__.__name__, inspect.currentframe().f_code.co_name) return False
def find_all_by_title(self, media_entry: MediaEntry, add_missing) -> List[Optional[Show]]: """ Search for plex shows within a configuration given library name :param add_missing: :param media_entry: media to look for :return: list of optional shows """ all_shows = list() try: anime_section: Optional[ShowSection] = self.plex.library.section(self.config['section_library_name']) if anime_section is not None: search_result: SearchResult = self.__search_for_shows(anime_section, media_entry) if search_result.search_results: for show in search_result.search_results: show_episodes_count = len(show.episodes()) episodes = media_entry.media.episodes if show_episodes_count >= episodes: continue all_shows.append(show) else: print() search_term = media_entry.media.title.userPreferred EventLogHelper.log_warning( f"Search term not found `{search_term}`, adding to missing shows list", self.__class__.__name__, inspect.currentframe().f_code.co_name ) print() add_missing() except Exception as e: EventLogHelper.log_info( f"{e}", self.__class__.__name__, inspect.currentframe().f_code.co_name ) return all_shows