Example #1
0
    def run(self):
        self.coparent.bu_sync_sync.Enable(False)
        for x in range(0, self.parent.lc_playlist.GetItemCount()):
            artist = self.parent.lc_playlist.GetItem(x, C_ARTIST).GetText()
            track = self.parent.lc_playlist.GetItem(x, C_SONG).GetText()
            query_string = artist + ' ' + track
            #check for file locally
            local_file = self.SearchLocal(query_string, artist, track)
            copy_file = None
            if local_file != None:
                copy_file = local_file
            else:
                #check for cached file
                copy_file = self.SearchCache(artist, track)

            self.coparent.ga_sync_progress.SetValue(x + 1)

            if copy_file != None:
                #copy the file
                file_name_plain = artist + '-' + track + '.mp3'
                file_name_plain = system_files.replace_all(file_name_plain)
                #charset = 'utf-8'
                ufile_string = string_tools.unescape(
                    file_name_plain)  #.encode(charset)
                #hex_file_name = hashlib.md5(ufile_string).hexdigest()
                #destination_file = self.sync_dir.encode(charset) + os.sep.encode(charset) + ufile_string # + '.mp3'
                destination_file = string_tools.unescape(
                    self.sync_dir) + string_tools.unescape(
                        os.sep) + ufile_string  # + '.mp3'
                self.coparent.st_sync_file.SetLabel(ufile_string)

                if os.path.isfile(destination_file) == False:
                    try:
                        shutil.copy(copy_file, destination_file)
                        #print destination_file
                    except Exception, expt:
                        self.coparent.ErrorMessage(expt)
                        break
                    if self.coparent.cb_sync_album.IsChecked():
                        #check if we want to rename the id3 tag for the album to something standard to help crappy mp3 players that don't list by folders
                        album_name = self.coparent.cm_sync_album_name.GetValue(
                        )
                        local_songs.SetMp3Album(destination_file, album_name)
Example #2
0
 def GetDeviceFreeSpace(self, path):
     # gets drive free space
     # print path
     if os.path.isdir(path):
         path_cmd = string_tools.unescape("dir " + path)
         try:
             x = os.popen(path_cmd, "rb").readlines()
             return x[-1].strip()
         except Exception, expt:
             print str(Exception) + str(expt)
             return " "
Example #3
0
 def GetDeviceFreeSpace(self, path):
     #gets drive free space
     #print path
     if os.path.isdir(path):
         path_cmd = string_tools.unescape('dir ' + path)
         try:
             x = os.popen(path_cmd, 'rb').readlines()
             return x[-1].strip()
         except Exception, expt:
             print str(Exception) + str(expt)
             return ' '
Example #4
0
    def run(self):
        self.coparent.bu_sync_sync.Enable(False)
        for x in range(0, self.parent.lc_playlist.GetItemCount()):
            artist = self.parent.lc_playlist.GetItem(x, C_ARTIST).GetText()
            track = self.parent.lc_playlist.GetItem(x, C_SONG).GetText()
            query_string = artist + " " + track
            # check for file locally
            local_file = self.SearchLocal(query_string, artist, track)
            copy_file = None
            if local_file != None:
                copy_file = local_file
            else:
                # check for cached file
                copy_file = self.SearchCache(artist, track)

            self.coparent.ga_sync_progress.SetValue(x + 1)

            if copy_file != None:
                # copy the file
                file_name_plain = artist + "-" + track + ".mp3"
                file_name_plain = system_files.replace_all(file_name_plain)
                # charset = 'utf-8'
                ufile_string = string_tools.unescape(file_name_plain)  # .encode(charset)
                # hex_file_name = hashlib.md5(ufile_string).hexdigest()
                # destination_file = self.sync_dir.encode(charset) + os.sep.encode(charset) + ufile_string # + '.mp3'
                destination_file = (
                    string_tools.unescape(self.sync_dir) + string_tools.unescape(os.sep) + ufile_string
                )  # + '.mp3'
                self.coparent.st_sync_file.SetLabel(ufile_string)

                if os.path.isfile(destination_file) == False:
                    try:
                        shutil.copy(copy_file, destination_file)
                        # print destination_file
                    except Exception, expt:
                        self.coparent.ErrorMessage(expt)
                        break
                    if self.coparent.cb_sync_album.IsChecked():
                        # check if we want to rename the id3 tag for the album to something standard to help crappy mp3 players that don't list by folders
                        album_name = self.coparent.cm_sync_album_name.GetValue()
                        local_songs.SetMp3Album(destination_file, album_name)
Example #5
0
def CleanText(text):
    if text != None:
        text = text.strip()
        text = text.replace('\r\n', '')
        text = text.replace('\n', '')
        text = text.replace('  ', ' ')
        #text = text.replace('&', '&')
        text = string_tools.unescape(text)
        #text = url_quote(text)
    else:
        text = ''
    return text
Example #6
0
 def SearchLocal(self, query_string, artist, track):
     # check locally for song
     # query_results = local_songs.GetResults(query_string, 1)
     query_results = local_songs.DbFuncs().GetSpecificResultArray(query_string, artist, track)
     # GetResultsArray(query, qlimit, with_count=False, folder_query=1)
     song_id = ""
     if len(query_results) >= 1:
         # song_id = str(query_results[0])
         song_id = string_tools.unescape(query_results[0][4])  # str(query_results[0][4]).encode('utf-8')
     # check if file exists
     if os.path.isfile(song_id):
         return song_id
     else:
         return None
Example #7
0
 def SearchLocal(self, query_string, artist, track):
     # check locally for song
     #query_results = local_songs.GetResults(query_string, 1)
     query_results = local_songs.DbFuncs().GetSpecificResultArray(
         query_string, artist, track)
     #GetResultsArray(query, qlimit, with_count=False, folder_query=1)
     song_id = ''
     if len(query_results) >= 1:
         #song_id = str(query_results[0])
         song_id = string_tools.unescape(
             query_results[0][4])  #str(query_results[0][4]).encode('utf-8')
     #check if file exists
     if os.path.isfile(song_id):
         return song_id
     else:
         return None