예제 #1
0
def passDir (rootdir):
	tags = []
	songs = []
	titles = []
	artists = []
	albums = []
	for song in os.listdir(rootdir):
		if (	os.path.isfile(os.path.join(rootdir,song)) 
			and mp3FileName.match (song)):
			filename = os.path.join(rootdir,song)
			tag = eyed3.Tag()
            try:
				if not tag.(filename):
					continue  #somthing wrong whith this file
			except:
				print '\n',filename,':error, may be tag is corrupted.\n '
				continue
			if recodingNeed ([tag.getTitle(),tag.getArtist(),tag.getAlbum()]) or restoreMode:
				if not os.access(filename,os.W_OK):
					print 'Warning! Have not access for writing file '\
					,filename , ' Sciped!'
					continue
				tags.append (tag)
				songs.append (song)
				if not restoreMode : #normal mode
					titles.append (getTagStr (tag.getTitle()))
					artists.append (getTagStr (tag.getArtist()))
					albums.append (getTagStr (tag.getAlbum()))
				else: #restore mode
					titles.append (tag.getTitle())
					artists.append (tag.getArtist())
					albums.append (tag.getAlbum())
	if len (tags) > 0:
		print len(tags),' file(s) finded in the ',rootdir
		askUser (tags,songs,titles,artists,albums)
예제 #2
0
파일: meyed3.py 프로젝트: cheshami/MD3
def embed_album_art(self, mp3_file, artwork_file, artist, item_title):
    #### TODO
    ## NOT WORKING
    #edit the ID3 tag to add the title, artist, artwork, date, and genre
    tag = eyed3.Tag()
    tag.link(mp3_file)
    tag.setVersion([2,3,0])
    tag.addImage(0x08, artwork_file)
    tag.setArtist(artist)
    tag.setDate(localtime().tm_year)
    tag.setTitle(item_title)
    tag.setGenre(u"Trance")
    tag.update()
예제 #3
0
def convertDirMP3ToWav(dirName, Fs, nC, useMp3TagsAsName=False):
    '''
	This function converts the MP3 files stored in a folder to WAV. If required, the output names of the WAV files are based on MP3 tags, otherwise the same names are used.
	ARGUMENTS:
	 - dirName:		the path of the folder where the MP3s are stored
	 - Fs:			the sampling rate of the generated WAV files
	 - nC:			the number of channesl of the generated WAV files
	 - useMp3TagsAsName: 	True if the WAV filename is generated on MP3 tags
	'''

    types = (dirName + os.sep + '*.mp3', )  # the tuple of file types
    filesToProcess = []

    tag = eyed3.Tag()

    for files in types:
        filesToProcess.extend(glob.glob(files))

    for f in filesToProcess:
        tag.link(f)
        if useMp3TagsAsName:
            artist = tag.getArtist()
            title = tag.getTitle()
            if len(title) > 0 and len(artist) > 0:
                wavFileName = ntpath.split(f)[0] + os.sep + artist.replace(
                    ",", " ") + " --- " + title.replace(",", " ") + ".wav"
            else:
                wavFileName = f.replace(".mp3", ".wav")
        else:
            wavFileName = f.replace(".mp3", ".wav")
        command = "avconv -i \"" + f + "\" -ar " + str(Fs) + " -ac " + str(
            nC) + " \"" + wavFileName + "\""
        print command
        os.system(
            command.decode('unicode_escape').encode('ascii', 'ignore').replace(
                "\0", ""))
예제 #4
0
    def update_mp3_listing(self, folder_path):
        self.current_folder_path = folder_path
        self.list_ctrl.ClearAll()

        self.list_ctrl.InsertColumn(0, 'Artist', width=140)
        self.list_ctrl.InsertColumn(1, 'Album', width=140)
        self.list_ctrl.InsertColumn(2, 'Title', width=200)
        self.list_ctrl.InsertColumn(3, 'Year', width=200)

        # Lame CRC error. Might have something to do with glob finding directory pathname
        mp3s = glob.glob(folder_path + '/*.mp3')
        # Debug code 2
        for items in mp3s:
            if eyed3.mp3.isMp3File(items):
                print('This is a mp3 file')
                tag = eyed3.Tag()

        # Debug code
        '''
        for items in mp3s:
            print(items)
            mp3_object = eyed3.load(items)
            mp3_object = eyed3.load(items)
            print(mp3_object.tag.artist)    
        '''
        # End debug
        mp3_objects = []
        index = 0
        for mp3 in mp3s:
            mp3_object = eyed3.load(mp3)
            self.list_ctrl.InsertItem(index, mp3_object.tag.artist)
            self.list_ctrl.SetItem(index, 1, mp3_object.tag.album)
            self.list_ctrl.SetItem(index, 2, mp3_object.tag.title)
            mp3_objects.append(mp3_object)
            self.row_obj_dict[index] = mp3_object
            index += 1
예제 #5
0
import eyed3

tag = eyed3.Tag()
tag.link("good.mp3")
print(tag.artist)