Exemple #1
0
	def _retrieve_movie_info(self, pathname):

		_ext = os.path.splitext(pathname)[1][1:]
		if not _ext.lower() in self.settings.MediaExt:
			raise NotMediaFile

		if self.args.check_video:
			if chkVideoFile(pathname):
				log.error('File Failed Video Check: {}'.format(pathname))
				raise NoValidFilesFound

		try:
			_movie_details = self.fileinfo.get_movie_details(pathname)
		except (MovieNotFound):
			raise
		try:
			_movie_details = self.tmdbinfo.tmdb(_movie_details)
		except MovieNotFound:
			try:
				# Movie wasn't found by filename try Directory Name
				_dir_name = os.path.dirname(pathname) + '.' + _ext
				_directory_details = self.fileparser.getFileDetails(_dir_name)
				_movie_details['MovieName'] = _directory_details['MovieName']
				_movie_details = self.tmdbinfo.tmdb(_movie_details)
			except (InvalidFilename, UnexpectedErrorOccured, RegxSelectionError):
				raise

		return _movie_details
Exemple #2
0
    def rename(self, pathname=None):

        if pathname:
            self.filename = pathname
            self.media_details(pathname)
        if not self.filename \
          or not exists(self.filename) \
          or not self.filename[:len(DadVision.settings.MoviesDir)] == DadVision.settings.MoviesDir:
            raise InvalidFilename("Filename missing or does not exist")

        if DadVision.args.check_video:
            if chkVideoFile(self.filename):
                log.error('File Failed Video Check: {}'.format(self.filename))
                raise FailedVideoCheck("File Failed Video Check: {}".format(
                    self.filename))

        try:
            if not self.validated:
                self.search()
            _year = ""
            if self.year:
                _year = " ({})".format(self.year)
            _other = ""
            if self.other and not self.other.lower() == 'proper':
                _other = " [{}]".format(self.other)
            new_dirname = "".join([self.title, _year])
            new_filename = "".join([new_dirname, _other, ".", self.container])
            new_filename_fq = join(DadVision.settings.MoviesDir, new_dirname,
                                   new_filename)
            if duplicate(self.filename, new_filename_fq, self.other): return
            rename_file(self.filename, new_filename_fq)
        except (MovieNotFound, TitleFromFileError, NotMediaFile), e:
            log.error("Unable to locate movie information, rename canceled")
            raise
Exemple #3
0
    def _retrieve_movie_info(self, pathname):

        _ext = os.path.splitext(pathname)[1][1:]
        if not _ext.lower() in self.settings.MediaExt:
            raise NotMediaFile

        if self.args.check_video:
            if chkVideoFile(pathname):
                log.error('File Failed Video Check: {}'.format(pathname))
                raise NoValidFilesFound

        try:
            _movie_details = self.fileinfo.get_movie_details(pathname)
        except (MovieNotFound):
            raise
        try:
            _movie_details = self.tmdbinfo.tmdb(_movie_details)
        except MovieNotFound:
            try:
                # Movie wasn't found by filename try Directory Name
                _dir_name = os.path.dirname(pathname) + '.' + _ext
                _directory_details = self.fileparser.getFileDetails(_dir_name)
                _movie_details['MovieName'] = _directory_details['MovieName']
                _movie_details = self.tmdbinfo.tmdb(_movie_details)
            except (InvalidFilename, UnexpectedErrorOccured,
                    RegxSelectionError):
                raise

        return _movie_details
Exemple #4
0
    def rename(self, pathname=None):

        if pathname:
            self.filename = pathname
            self.media_details(pathname)
        if (
            not self.filename
            or not exists(self.filename)
            or not self.filename[: len(DadVision.settings.MoviesDir)] == DadVision.settings.MoviesDir
        ):
            raise InvalidFilename("Filename missing or does not exist")

        if DadVision.args.check_video:
            if chkVideoFile(self.filename):
                log.error("File Failed Video Check: {}".format(self.filename))
                raise FailedVideoCheck("File Failed Video Check: {}".format(self.filename))

        try:
            if not self.validated:
                self.search()
            _year = ""
            if self.year:
                _year = " ({})".format(self.year)
            _other = ""
            if self.other and not self.other.lower() == "proper":
                _other = " [{}]".format(self.other)
            new_dirname = "".join([self.title, _year])
            new_filename = "".join([new_dirname, _other, ".", self.container])
            new_filename_fq = join(DadVision.settings.MoviesDir, new_dirname, new_filename)
            if duplicate(self.filename, new_filename_fq, self.other):
                return
            rename_file(self.filename, new_filename_fq)
        except (MovieNotFound, TitleFromFileError, NotMediaFile), e:
            log.error("Unable to locate movie information, rename canceled")
            raise