Esempio n. 1
0
def setTag(mp3, type):
    """
    Set tag from MP3 file (mp3 = eyed3.load("File.mp3"))
    allowed value of type 'album','artist','album_artist','title',
    'track_num','genre','year','total_track'
    """
    if type != "track":
        extra.log(type, "=", getFinalTag(mp3, type))

    if type == "album":
        mp3.tag.album = unicode(getFinalTag(mp3, "album"))
    elif type == "artist":
        mp3.tag.artist = unicode(getFinalTag(mp3, "artist"))
    elif type == "album_artist":
        mp3.tag.album_artist = unicode(getFinalTag(mp3, "album_artist"))
    elif type == "title":
        mp3.tag.title = unicode(getFinalTag(mp3, "title"))
    elif type == "track":
        # Track_num = (TrackNumber, Total Track) //Tuple
        track_num = getFinalTag(mp3, "track_num")
        total_track = getFinalTag(mp3, "total_track")
        extra.log(type, "=", track_num, total_track)
        mp3.tag.track_num = (track_num, total_track)
    elif type == "genre":
        mp3.tag.genre = unicode(getFinalTag(mp3, "genre"))
    elif type == "year":
        mp3.tag.release_date = getFinalTag(mp3, "year")
Esempio n. 2
0
def getcoverURL(search, resultCount=10):
    '''
    It will return the URL to coverart image
    '''
    extra.cls()
    # search = "drishyam"
    # resultCount = 10
    # This Custom Search Engine of google, search on www.saavn.com
    #  and itunes.apple.com for albums
    searchengineid = "014954134512375095903%3A1jlepwhgf1k"
    APIKey = str(raw_input("Please enter your Google API Key \n \
        Press 0 to browse image instead from your computer\n>> "))
    if APIKey == '0':
        return False
    print "Searching for " + search + "\n Do you wish to change album name (Y/N)?"
    ch = str(raw_input(">> ")).lower()
    if ch == 'y':
        search = str(raw_input("Enter Album name to search\n>> "))
    extra.log("Searching for " + search + "\n")
    url = "https://www.googleapis.com/customsearch/v1?" + \
        "q=" + search + \
        "&num=" + str(resultCount) + \
        "&cx=" + searchengineid + \
        "&key=" + APIKey
    extra.log("SearchURL = " + url)

    try:
        source = urlopen(url)
    except:
        extra.log("Can't connect to internet, unable to edit cover image")
        raw_input("Internet Issues, Press any key to browse cover image")
        return False
    # source = open('json.txt').read()

    parsedJSON = json_loads(source.read())

    if "error" in parsedJSON:
        extra.log("Please Update API Key")
        return False

    i = 1
    for each in parsedJSON["items"]:
        print i, each["title"], each["displayLink"]
        i += 1
    print "Enter your choice\n>> ",
    ch = int(input())
    # ch = 4
    url = parsedJSON["items"][ch - 1]["pagemap"]["cse_image"][0]["src"]
    if parsedJSON["items"][ch - 1]["displayLink"] == "www.saavn.com":
        pass
    else:
        url = url.replace("326x326", "600x600")

    return url
Esempio n. 3
0
    Works great with MP3 folder

    NOT TO BE USED WITH FOLDER, CONTAINING MP3 FROM DIFF ALBUMs

    Press any key to continue, and select the folder to start the process

>> """,

raw_input()

root = Tk()
root.withdraw()
extra.clearlog()

dirname = askdirectory(parent=root, title="Please select a directory")
extra.log("Dirname = " + dirname)
extra.cls()
# dirname = r'/home/ashwani/Music'
final = dict()
extra.log(str(final))


def getlistofMP3s(dirname):
    """
    Returns a list of MP3 file names
    """
    l = []
    for i in os_listdir(dirname):
        if str(i[-3:]).lower() == "mp3":
            l += [i]
    return l