示例#1
0
 def _upgrade( self ):
     #this is where any code goes for one time upgrade routines
     loglines, data = readFile( self.CHECKFILE )
     lw.log( loglines )
     if not data:
         self._migrate_info_files()
     loglines, data = readFile( self.CHECKFILE )
     if data == '1.5.4':
         self._migrate_tbn_files()
示例#2
0
 def _jsonfix( self, show, jsonpath ):
     video_files = []
     nfo_files = []
     ext_dict = {}
     try:
         items = os.listdir( self.FOLDERPATH )
     except OSError:
         err_str = 'directory %s not found' % self.FOLDERPATH
         lw.log( [err_str, 'script stopped'] )
         sys.exit( err_str )
     jsondata = readFile( jsonpath )
     lw.log( ['-----JSON data-----', jsondata[1]] )
     episodes = _json.loads( jsondata[1] )
     for item in items:
         fileroot, ext = os.path.splitext( item )
         processfilepath = os.path.join( self.FOLDERPATH, item )
         last_mod = time.strftime( '%Y-%m-%d', time.localtime( os.path.getmtime( processfilepath ) ) )
         if ext in settings.video_exts :
             for key in episodes:
                 episode = episodes[key]
                 lw.log( ['comparing file last mod of %s with json record date of %s' % (last_mod, episode['record-date'])] )
                 if last_mod == episode['record-date']:
                     newfilename = '%s.S%sE%s.%s%s' % (show, episode['season'], episode['episode'], episode['title'], ext)
                     newfilepath = os.path.join( self.FOLDERPATH, newfilename )
                     exists, loglines = checkPath( newfilepath, create=False )
                     lw.log( loglines )
                     if not exists:
                         success, loglines = renameFile( processfilepath, newfilepath )
                         lw.log( loglines )
                         if success:
                             self._update_db( newfilepath )
                     else:
                         lw.log( ['%s already has the correct file name' % processfilepath] )
                     break
示例#3
0
 def _get_musicbrainz_id ( self, theartist, mbid ):
     if mbid:
         return mbid
     lw.log( ['Looking for a musicbrainz ID for artist ' + theartist, 'Looking for musicbrainz ID in the musicbrainz.nfo file'] )
     self._set_infodir( theartist )
     filename = os.path.join( self.InfoDir, 'musicbrainz.nfo' )
     if xbmcvfs.exists( filename ):
         loglines, mbid = readFile( filename )
         lw.log( loglines )
         if not mbid:
             lw.log( ['no musicbrainz ID found in musicbrainz.nfo file'] )
             return ''
         else:
             lw.log( ['musicbrainz ID found in musicbrainz.nfo file'] )
             return mbid
     else:
         lw.log( ['no musicbrainz.nfo file found'] )
         return ''
示例#4
0
 def _write_nfofile( self, nfotemplate, ep_info, newnfoname ):
     newnfopath = os.path.join( self.FOLDERPATH, newnfoname )
     replacement_dic = {
         '[SEASON]': ep_info['season'],
         '[EPISODE]' : ep_info['episode'],
         '[TITLE]' : ep_info['title'],
         '[DESC]' : ep_info['description'],
         '[AIRDATE]' : ep_info["airdate"]}
     exists, loglines = checkPath( newnfopath, create=False )
     lw.log( loglines )
     if exists:
         success, loglines = deleteFile( newnfopath )
         lw.log( loglines )
     loglines, fin = readFile( nfotemplate )
     lw.log (loglines )
     if fin:
         newnfo = replaceWords( fin, replacement_dic )
         success, loglines = writeFile( newnfo, newnfopath )
         lw.log( loglines )