def postMovies(self): res = commands.getoutput("ls '%s'" % (LOCAL_MOVIE_PATH,)) tokens = res.split("\n") for token in tokens: if token not in self.movies: log.info("Found %s" % token) log.info("Found %s. Starting re-encoding..." % token) try: reencodeFilesInDirectory(token) except Exception, e: log.error("Error processing %s" % token) log.error(e) log.info("Posting %s" % (token,)) self._postMovie(token)
def postMovies(self): res = commands.getoutput("ls '%s'" % (LOCAL_MOVIE_PATH, )) tokens = res.split('\n') for token in tokens: if token not in self.movies: log.info("Found %s" % token) log.info("Found %s. Starting re-encoding..." % token) try: reencodeFilesInDirectory(token) except Exception, e: log.error("Error processing %s" % token) log.error(e) log.info("Posting %s" % (token, )) self._postMovie(token)
def run(self, iterations=1, dryRun=False): fileGen = self.getUnstreamableFiles() for i in xrange(iterations): try: fileList = fileGen.next() except StopIteration: break for file in fileList: if file['ismovie']: errors = reencodeFilesInDirectory(file['filename'], dryRun=dryRun) if errors: log.error("Something bad happened. Attempting to continue") for error in errors: log.error(errors) else: if not dryRun: self.putData(file['pk'], file['filename']) else: # Running update on a tv show fullPath = os.path.join(file['localpath'], file['filename']) try: fullPath = makeFileStreamable(fullPath, appendSuffix=True, removeOriginal=True, dryRun=dryRun) except Exception, e: print e log.error(e) log.error("Something bad happened. Attempting to continue") if os.path.exists(fullPath) and not dryRun: #TODO: Make call to update filename newFilename = os.path.basename(fullPath) if newFilename != file['filename']: self.putData(file['pk'], os.path.basename(fullPath))