def _filter(self, e):
     self.log.info(e)
     self.log.debug(file_name(self.path).lower())
     self.log.debug(dirname(self.path).lower())
     b1 = self._is_sample()
     b2 = dir_path(self.path) in e[1]
     self.log.debug("Folder %s is  handled: %s. %s is in %s: %s", path_leaf(dir_path(self.path)), b2, dir_path(self.path), e[1], b2)
     return b1 or b2
Example #2
0
 def _put_files_under_movie_dir(self, distributed_paths):
     for i, f in enumerate(distributed_paths):
         name, ext = file_name(f), file_extension(f)
         file_destination = path.join(dir_path(self.mn), name + ext)
         if f != file_destination:
             copyfile(f, file_destination, self.log)
         distributed_paths[i] = file_destination
 def _is_sample(self):
     sample = "sample"
     b1 = file_name(self.path).lower() == sample
     b2 = path_leaf(dir_path(self.path)).lower() == sample
     self.log.debug("File is  sample: %s", b1)
     self.log.debug("Folder is sample: %s", b2)
     return b1 or b2
Example #4
0
 def _extract_subtitles_to_movie_dir(self):
     extracted = False
     try:
         self.subzip.accessor.extractall(dir_path(self.mn))
         extracted = True
     except Exception as e:
         self.log.exception("Failed to extract: %s", e)
     return extracted
Example #5
0
 def _distributed_paths(self):
     if dir_path(self.sn) == self.sDir:
         self.log.info(
             "Additional adjusting of file locations for {} is not required."
             .format(self.sn))
         return [self.sn]
     t = path.relpath(self.sn, start=self.sDir)
     basedir = t.split(path.sep)[0]
     tt = path.join(self.sDir, basedir)
     return extract_file_paths(tt)
Example #6
0
 def _distributed_paths(self):
     return [
         path.join(dir_path(self.mn),
                   path.relpath(f, start=dir_path(self.sn)))
         for f in self._subs_file_paths()
     ]
Example #7
0
def _select_and_rename_subs(distributed_paths, movie_file_name):
    lucky_subs, random_index = _lucky_subs(distributed_paths)
    ext = file_extension(lucky_subs)
    new_file_name = path.join(dir_path(lucky_subs), movie_file_name + ext)
    move(distributed_paths[random_index], new_file_name)
Example #8
0
 def _extractfile(self):
     self.log.info("Start extracting %s to: %s", self.sn, dir_path(self.mn))
     extracted = self._extract_subtitles_to_movie_dir()
     self.log.info("End extracting %s to: %s - with result %s", self.sn,
                   dir_path(self.mn), repr(extracted))
     return extracted