def __init__(self, filepath = None): """ constructor. takes the complete movie file path, or nothing if you want to create a movie example """ # create a movie example if filepath == None: # file path (only directory) self.path_ = 'C:\\' # original movie title, before renaming self.original_name_ = '[DivX ITA] A really cool movie (2012)' # file extension self.extension_ = '.avi' # movie new title (after renaming) self.new_name_ = '' # current state # states are used to show a proper panel in GUI self.state_ = self.STATE_BEFORE_RENAMING self.guessed_info_ = { self.SUBTITLES: ['Italian', 'ITA'], self.PART: '1'} info = { self.TITLE: 'Un film molto figo', self.ORIGINAL_TITLE: 'A really cool movie', self.YEAR: '2012', self.DIRECTOR: 'A. Director', self.DURATION: ['100m', '1h40m'], self.LANGUAGE: ['Italian', 'ITA'], self.SCORE: 1} self.others_info_ = [info] self.info_ = info else: path, name = os.path.split(filepath) name, extension = os.path.splitext(name) # file path (only directory) self.path_ = os.path.normpath(unicode(path)) # original movie title, before renaming self.original_name_ = unicode(name) # file extension self.extension_ = unicode(extension) # movie new title (after renaming) self.new_name_ = '' # current state # states are used to show a proper panel in GUI self.state_ = self.STATE_BEFORE_RENAMING # error occurred during renaming operation self.renaming_error_ = '' # used to store guessed information from file name self.guessed_info_ = None # imdb search for a given movie, return some results, which are # transformed in a better formed and stored into this attribute self.others_info_ = None # currently associated movie, returned from imdb search, is stored here self.info_ = None # get video duration self.video_duration_ = None try: video_info = enzyme.parse(self.abs_original_file_name()) except Exception: import traceback import exceptionhandler exceptionhandler.save_exception() traceback.print_exc() else: if video_info.length != None: self.video_duration_ = int(video_info.length / 60) elif video_info.video[0].length != None: self.video_duration_ = int(video_info.video[0].length / 60) # guess info from file name self.guessed_info_ = guess_info(name) # get other movie info self.get_info_()
# using version 2 of SIP API sip.setapi('QString', 2) from PyQt4.QtCore import QTranslator, QLocale from PyQt4.QtGui import QApplication import sys import utils from gui import GUI # load languages and preferences utils.load_languages() utils.load_preferences() # create the GUI and shows it app = QApplication(sys.argv) # load translation translator = QTranslator() translator.load("qm/app_" + QLocale.system().name()) app.installTranslator(translator) # show gui gui = GUI() gui.show() # execute the application app.exec_() except: import traceback import exceptionhandler exceptionhandler.save_exception() traceback.print_exc()