def _convert_playlist_to_v2():
 if os.path.isfile(g.PLFILE):
  return
 elif (not os.path.isfile(g.OLD_PLFILE)):
  return
 try:
  with open(g.OLD_PLFILE, 'rb') as plf:
   old_playlists = pickle.load(plf)
 except IOError:
  sys.exit("Couldn't open old playlist file")
 backup = (g.OLD_PLFILE + '_v1_backup')
 if os.path.isfile(backup):
  sys.exit('Error, backup exists but new playlist exists not!')
 os.rename(g.OLD_PLFILE, backup)
 for (plname, plitem) in old_playlists.items():
  songs = []
  for video in plitem.songs:
   v = Video(video['link'], video['title'], video['duration'])
   songs.append(v)
  g.userpl[plname] = Playlist(plname, songs)
 save()

def _convert_playlist_to_v2 ( ) : if os . path . isfile ( g . PLFILE ) : return elif ( not os . path . isfile ( g . OLD_PLFILE ) ) : return try : with open ( g . OLD_PLFILE , 'rb' ) as plf : old_playlists = pickle . load ( plf ) except IOError : sys . exit ( "Couldn't open old playlist file" ) backup = ( g . OLD_PLFILE + '_v1_backup' ) if os . path . isfile ( backup ) : sys . exit ( 'Error, backup exists but new playlist exists not!' ) os . rename ( g . OLD_PLFILE , backup ) for ( plname , plitem ) in old_playlists . items ( ) : songs = [ ] for video in plitem . songs : v = Video ( video [ 'link' ] , video [ 'title' ] , video [ 'duration' ] ) songs . append ( v ) g . userpl [ plname ] = Playlist ( plname , songs ) save ( )
convert previous playlist file to v2 playlist .