def getURL(baseUrl, song_name, tags):
    # get the search url using album or artist or year or only name

    song_name = song_name.lower().strip()

    if tools.isTagPresent(tags, 'album') and \
            tools.removeYear(tags['album'][0]).lower().strip() != song_name:

        album = tools.removeYear(tags['album'][0]).lower().strip()
        album = tools.removeGibberish(album)

        url = baseUrl.format(song_name + ' ' + album)

    elif tools.isTagPresent(tags, 'artist'):

        oldArtist = tools.removeGibberish(tags['artist'][0])
        newArtist = tools.divideBySColon(oldArtist)

        newArtist = tools.removeTrailingExtras(newArtist)
        newArtist = tools.removeDup(newArtist)

        url = baseUrl.format(song_name + ' ' + newArtist)

    elif tools.isTagPresent(tags, 'date'):
        url = baseUrl.format(song_name + ' ' + tags['date'][0])
    else:
        url = baseUrl.format(song_name)
    return url.replace(" ", '+')
def fix(song_info, test=0):
    oldArtist = song_info["primary_artists"]
    newArtist = tools.removeGibberish(oldArtist)
    newArtist = tools.divideBySColon(newArtist)
    newArtist = tools.removeTrailingExtras(newArtist)
    song_info['primary_artists'] = tools.removeDup(newArtist)

    song_info["singers"] = song_info['primary_artists']

    old_composer = song_info["music"]
    new_composer = tools.removeGibberish(old_composer)
    new_composer = tools.divideBySColon(new_composer)
    new_composer = tools.removeTrailingExtras(new_composer)
    song_info["music"] = tools.removeDup(new_composer)

    song_info['image'] = song_info['image'].replace('-150x150.jpg',
                                                    '-500x500.jpg')

    # ---------------------------------------------------------------#

    new_title = song_info['title'].replace('"', '#')
    if new_title != song_info['title']:
        song_info['title'] = new_title
        song_info['title'] = tools.removeGibberish(song_info['title'])

        x = re.compile(
            r'''
                                (
                                [(\[]
                                .*          # 'featured in' or 'from' or any other shit in quotes
                                \#(.*)\#      # album name
                                [)\]]
                                )
                                ''', re.VERBOSE)

        album_name = x.findall(song_info['title'])
        song_info['title'] = song_info['title'].replace(album_name[0][0],
                                                        '').strip()

        song_info['actual_album'] = album_name[0][1]

        # old method, if above wont work, this will work 9/10 times.
        # json_data = re.sub(r'.\(\b.*?"\)', "", str(info.text))
        # json_data = re.sub(r'.\[\b.*?"\]', "", json_data)
        # actual_album = ''

    else:
        song_info['actual_album'] = ''

    song_info['title'] = tools.removeGibberish(song_info['title'])
    song_info["album"] = tools.removeGibberish(song_info["album"]).strip()

    if test:
        print(json.dumps(song_info, indent=2))
def fixArtist(tags):
    try:
        oldArtist = tags['artist'][0]
        print("Curr Artist: ", oldArtist)
    except KeyError:
        print("No Artist was found in tags, moving on...")
        return

    # old one
    # oldArtist = ';'.join(re.split(r'/|,|& ', oldArtist))

    # 2nd old method
    # oldArtist = re.sub(r'\s*&\s*|\s*/\s*|\s*,\s*', ';', oldArtist)
    # oldArtist = re.sub(r';\s*;\s*|;\s*', '; ', oldArtist)

    # new method
    newArtist = tools.removeGibberish(oldArtist)
    newArtist = tools.divideBySColon(newArtist)

    newArtist = tools.removeTrailingExtras(newArtist)
    newArtist = tools.removeDup(newArtist)

    if newArtist != oldArtist:
        tags['artist'] = newArtist
        tags.save()
        print("New Artist: ", newArtist)
Beispiel #4
0
def modifyTitle(tags):
    try:
        oldTitle = tags['title'][0]
        print("Curr Title: ", tags['title'][0])
    except KeyError:
        print("No Title was found in tags, moving on...")
        return

    newTitle = tools.removeSiteName(oldTitle)
    newTitle = tools.removeGibberish(newTitle)
    newTitle = newTitle.strip()

    if oldTitle != newTitle:
        tags['title'] = newTitle
        tags.save()
        print("New Title : ", newTitle)
def fixAlbum(tags, date):
    print("Curr Album Name: ", tags['album'][0])

    oldAlbumName = tags['album'][0]
    newName = tools.removeYear(oldAlbumName)
    newName = tools.removeGibberish(newName)

    if date != '':
        newAlbumName = newName + ' (' + date + ')'
    else:
        newAlbumName = newName

    if oldAlbumName != newAlbumName:
        tags['album'] = newAlbumName
        tags.save()
        print("New Album Name : ", newAlbumName)
Beispiel #6
0
def fixComposer(tags):
    try:
        old_composer = tags['composer'][0]
        print("Composer: ", old_composer)
    except:
        traceback.print_exc()

        print("No Composer was found in tags, moving on...")
        return

    new_composer = tools.removeGibberish(old_composer)
    new_composer = tools.divideBySColon(new_composer)

    new_composer = tools.removeTrailingExtras(new_composer)
    new_composer = tools.removeDup(new_composer)

    if new_composer != old_composer:
        tags['composer'] = new_composer
        tags.save()
        print("New Composer: ", new_composer)
        return
Beispiel #7
0
def handleSongsInDir(song_dir, files, sub_dir_flag=-1, test=0):
    print('Now in ', song_dir)

    if not sub_dir_flag and not int(input("Do you upgrade songs in " + song_dir + " ?\n1 == Yes, 0 == NO\n")):
        return

    log_file = tools.createLogFile(song_dir)
    song_list = getSongList(files)

    try:
        print("Creating downloads and done directory in current folder...")

        download_dir = os.path.join(song_dir, 'Downloaded_songs')
        done_dir = os.path.join(song_dir, 'Done')

        os.mkdir(download_dir)
        os.mkdir(done_dir)
    except FileExistsError:
        print(
            "\n ==================== Since download directory already exists, I will save songs in it. ==================== ")

    # noinspection PyUnboundLocalVariable
    print("Download dir =", download_dir, '\n')

    for song in song_list:
        song_name = tools.removeBitrate(song)
        song_name = tools.removeGibberish(song_name)
        song_name = song_name.replace('.mp3', '')
        song_name = song_name.strip()
        print("Song Name: ", song_name)

        try:
            downloadSong.start(song_name, song_dir, download_dir, log_file, test=test)
        except:
            print(" ==================== There Was Some Error Downloading {0} ==================== ".format(song_name))
            tools.writeAndPrintLog(log_file,
                                   "\n ==================== Error Downloading song={0} ==================== \n".format(
                                       song_name), test=test)