コード例 #1
0
ファイル: util.py プロジェクト: foxhead128/akane
def set_frames(filename, valuedict, act=True, verbose=False):
    try:
        tag = stagger.read_tag(filename)
    except stagger.NoTagError:
        verb(verbose, "{0}: new ID3v2.{1} tag".format(filename, stagger.default_tag.version))
        tag = stagger.default_tag()
    for (key, value) in valuedict.items():
        if key.lower() in tag._friendly_names:
            # Use friendly name API
            key = key.lower().replace("-", "_")
            assert hasattr(tag, key)
            setattr(tag, key, value)
            newval = repr(getattr(tag, key))
        else:
            # Use frameid API
            tag[key] = value
            newval = tag[key]
        verb(verbose, "{0}: {1}: set to {2}".format(filename, key, newval))
    if act:
        tag.write(filename)
コード例 #2
0
ファイル: util.py プロジェクト: kisdma/stagehand
def set_frames(filename, valuedict, act=True, verbose=False):
    try:
        tag = stagger.read_tag(filename)
    except stagger.NoTagError:
        verb(verbose, "{0}: new ID3v2.{1} tag"
             .format(filename, stagger.default_tag.version))
        tag = stagger.default_tag()
    for (key, value) in valuedict.items():
        if key.lower() in tag._friendly_names:
            # Use friendly name API
            key = key.lower().replace("-", "_")
            assert hasattr(tag, key)
            setattr(tag, key, value)
            newval = repr(getattr(tag, key))
        else:
            # Use frameid API
            tag[key] = value
            newval = tag[key]
        verb(verbose, "{0}: {1}: set to {2}".format(filename, key, newval))
    if act:
        tag.write(filename)
コード例 #3
0
ファイル: tags.py プロジェクト: darkfeline/vocaran_tools
def tag(file, id, title='', artist='', album='', comment='', apic='none'):
    """Tag the MP3 file using stagger.  
    
    comment is tagged as COMM, as opposed to USLT that nicomimi.net custom uses
    for comments/lyrics.  
    
    file should probably match the title and end in '.mp3' as the right
    extension.  See getpic for information about apic.  Additionally, if apic
    is 'none', no picture is tagged.
    
    """
    t = stagger.default_tag()
    t._filename = file
    t[TIT2] = title
    t[TPE1] = artist
    t[TALB] = album
    t[USLT] = USLT(text=comment)
    if apic != 'none':
        getpic(file + '.jpg', id, apic)
        t[APIC] = APIC(file + '.jpg')
        os.remove(file + '.jpg')
    t.write()
コード例 #4
0
		message = "Track " + str(tracks.index(track) + 1) + "/" + str(len(tracks))
		try:
			downloaded = Download(track["file"]["mp3-128"], f, message)
			if not downloaded:
				raise Exception
		except Exception:
			got_error = True
			print(message + " : File unavailable. Skipping...")
			continue

		# Tag.
		if can_tag == False : continue # Skip the tagging operation if stagger cannot be loaded.

		# Tag the file.
		try:
			tag = stagger.default_tag()
			tag.album = album["title"]
			tag.artist = artist
			if release_date.strftime("%H:%M:%S") == "00:00:00":
				tag.date = release_date.strftime("%Y-%m-%d")
			else:
				tag.date = release_date.strftime("%Y-%m-%d %H:%M:%S")
			tag.title = track["title"]
			tag.track = track["track_num"]
			tag.picture = artwork_full_name
			tag.write(f)
		except:
			print("[Warning] Can't add tags, skipped.")

	if got_error:
		print()