def __init__(self, movie_dict, g): super().__init__() # schema = MovieSchema() self.movie_dictionary = movie_dict self.shows_dictionary = self.movie_dictionary.get('Shows', dict()) cleanup_movie.cleanup_dict(self.movie_dictionary) self.tmbdid = self.movie_dictionary[ 'Movie DB ID'] # TODO: upgrade to be dynamic if missing by title if its a # single result g.LOG.debug(backend.debug_message(627, g, self.movie_dictionary)) g.LOG.debug(backend.debug_message(645, g, self.shows_dictionary)) g.LOG.debug(backend.debug_message(648, g, self.tmbdid)) ### FROM RADARR API FULL DICT self.alternativeTitles = list() self.audioLanguages = str( ) # should parse out multi language info here self.cleanMovieTitle = str() self.downloaded = bool() self.genres = str() self.hasFile = bool() self.imdbid = int() self.inCinemas = datetime self.isAvailable = bool() self.mediaInfo = str() self.monitored = bool() self.movieFileId = int() self.movieId = int() self.moviePath = str() self.movieQuality = str() self.movieRuntime = int() self.movieTitle = str() self.qualityProfileId = int() self.radarrProfileId = int() self.relativePath = str() self.runtime = int() # TODO: can use this to compare to sonarr self.sizeonDisk = int() self.sortTitle = str() self.titleslug = str() self.year = int() ################################################ ### NOT BY API CALL FOR NOW self.absolute_movie_file_path = str() self.extension = ".mkv" self.quality = str() self.relative_movie_path = str() ################################################ self.parse_dict_from_radarr(g)
def padded_absolute_episode(self, g): result = str() if isinstance(self.absoluteEpisodeNumber, list): result = "-".join([str(i).zfill(self.padding) for i in self.absoluteEpisodeNumber]) elif isinstance(self.absoluteEpisodeNumber, int): result = str(self.absoluteEpisodeNumber).zfill(self.padding) elif 'Parsed Absolute Episode' in self.inherited_series_dict: del self.inherited_series_dict['Parsed Absolute Episode'] result = str() elif result in [0, 00, '00', '000', None]: return str() g.LOG.debug(backend.debug_message(635, g, result)) return result
def symlink_force(movie, show, g): message.method_launch(g) os.chdir(g.MEDIA_PATH) if os.path.isfile(f"{cleanString(movie.absolute_movie_file_path)}"): process = subprocess.Popen([ "ln", "-fsvr", f"{cleanString(movie.absolute_movie_file_path)}", f"{cleanString(show.relative_show_file_path)}" ], stderr=subprocess.DEVNULL, stdout=subprocess.PIPE) process = re.sub("'", "", str(iter(process.communicate()).__next__())[3:-4]) g.LOG.info(backend.debug_message(654, g, process)) message.method_exit(g)
def parent_dict(g, movie_dict): result = movie_dict g.LOG.debug(backend.debug_message(627, g, result)) return result
def parse_dict_from_radarr(self, g): if validate_tmdbId(self.tmbdid): try: index = [ i for i, d in enumerate(g.full_radarr_dict) if (self.movie_dictionary['Movie DB ID'] in d.values()) and ("tmdbId" in d.keys() and d['tmdbId'] == self.movie_dictionary['Movie DB ID']) ][0] g.LOG.debug( backend.debug_message(644, g, g.full_radarr_dict[index])) items = g.full_radarr_dict[index] title = re.sub("\s+\(0\)\s?", str(), items.pop("title")) self.movieTitle = re.sub( "\s+\(0\)\s?", "", re.sub("/", "+", re.sub(":", "-", f"{title} (" f"{self.year})"))) self.hasFile = items.pop("hasFile") self.monitored = items.pop("monitored") self.year = items.get( 'year', 0 ) # if 'inCinemas' not in items else items.pop('inCinemas')[0:4] self.movieId = items.get("id", 0) self.downloaded = items.get("downloaded", False) self.imdbid = items.get("imdbId", 0) self.moviePath = items.pop("path") self.inCinemas = items.get("inCinemas", str()) self.radarrProfileId = items.pop("profileId") self.cleanMovieTitle = items.pop("cleanTitle") self.movieRuntime = items.pop( "runtime") # TODO: can use this to compare to sonarr self.genres = items.get("genres") self.titleslug = items.pop("titleSlug") self.isAvailable = items.pop("isAvailable") self.alternativeTitles = items.pop("alternativeTitles") self.sortTitle = items.pop("sortTitle") self.qualityProfileId = items.pop("qualityProfileId") if self.hasFile and "movieFile" in items and items["movieFile"]: self.movieFileId = items["movieFile"].get("id") self.movieId = items["movieFile"].pop("movieId") self.movieQuality = items["movieFile"].pop( "quality") # placeholder may use this at self.relativePath = self.movie_dictionary[ 'Movie File'] = items["movieFile"].pop("relativePath") self.quality = \ self.movie_dictionary['Parsed Movie Quality'] = \ str(self.movieQuality['quality']['name']) self.extension = re.sub( self.quality, str(), str(self.relativePath.split().pop())) self.mediaInfo = items["movieFile"].pop( "mediaInfo") # placeholder may use this at self.sizeonDisk = items["movieFile"].pop("size") self.audioLanguages = self.mediaInfo.get( "audioLanguages", str()) self.absolute_movie_file_path = \ self.movie_dictionary['Absolute Movie File Path'] = \ "/".join((self.moviePath, self.relativePath)).replace(":", "-") g.LOG.debug( backend.debug_message(615, g, self.absolute_movie_file_path)) g.LOG.debug(backend.debug_message(646, g, self.hasFile)) g.LOG.debug(backend.debug_message(647, g, self.monitored)) g.LOG.debug(backend.debug_message(617, g, self.moviePath)) g.LOG.debug(backend.debug_message(610, g, self.relativePath)) g.LOG.debug(backend.debug_message(612, g, self.quality)) del items del g.full_radarr_dict[index] except IndexError: pass
def relative_show_path(self, g): result = self.inherited_series_dict['Relative Show Path'] = f"{self.path}/{self.seasonFolder}" g.LOG.debug(backend.debug_message(633, g, result)) return str(result)
def season_folder_from_api(self, g): result = self.inherited_series_dict['Parsed Season Folder'] = f"Season {self.season}" g.LOG.debug(backend.debug_message(631, g, result)) return result
def message_exiting_function(g): os.chdir(g.MEDIA_PATH) g.LOG.debug(debug_message(601, g))