Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
self.create_temp_dir()
self.key = "READ_ONLY_TEST"
self.field = mediafile.MediaField(
mediafile.MP3StorageStyle(self.key, read_only=True),
mediafile.MP4StorageStyle(
"----:com.apple.iTunes:" + self.key, read_only=True),
mediafile.StorageStyle(self.key, read_only=True),
mediafile.ASFStorageStyle(self.key, read_only=True),
)
if "read_only_test" not in mediafile.MediaFile.fields():
mediafile.MediaFile.add_field("read_only_test", self.field)
MP4StorageStyle('\xa9grp'),
StorageStyle('GROUPING'),
ASFStorageStyle('WM/ContentGroupDescription'),
)
track = MediaField(
MP3SlashPackStorageStyle('TRCK', pack_pos=0),
MP4TupleStorageStyle('trkn', index=0),
StorageStyle('TRACK'),
StorageStyle('TRACKNUMBER'),
ASFStorageStyle('WM/TrackNumber'),
out_type=int,
)
tracktotal = MediaField(
MP3SlashPackStorageStyle('TRCK', pack_pos=1),
MP4TupleStorageStyle('trkn', index=1),
StorageStyle('TRACKTOTAL'),
StorageStyle('TRACKC'),
StorageStyle('TOTALTRACKS'),
ASFStorageStyle('TotalTracks'),
out_type=int,
)
disc = MediaField(
MP3SlashPackStorageStyle('TPOS', pack_pos=0),
MP4TupleStorageStyle('disk', index=0),
StorageStyle('DISC'),
StorageStyle('DISCNUMBER'),
ASFStorageStyle('WM/PartOfSet'),
out_type=int,
)
disctotal = MediaField(
MP3SlashPackStorageStyle('TPOS', pack_pos=1),
MP4TupleStorageStyle('disk', index=1),
)
genre = MediaField(
mp3 = StorageStyle('TCON'),
mp4 = StorageStyle("\xa9gen"),
etc = StorageStyle('GENRE'),
asf = StorageStyle('WM/Genre'),
)
composer = MediaField(
mp3 = StorageStyle('TCOM'),
mp4 = StorageStyle("\xa9wrt"),
etc = StorageStyle('COMPOSER'),
asf = StorageStyle('WM/Composer'),
)
grouping = MediaField(
mp3 = StorageStyle('TIT1'),
mp4 = StorageStyle("\xa9grp"),
etc = StorageStyle('GROUPING'),
asf = StorageStyle('WM/ContentGroupDescription'),
)
track = MediaField(out_type=int,
mp3 = StorageStyle('TRCK', packing=packing.SLASHED, pack_pos=0),
mp4 = StorageStyle('trkn', packing=packing.TUPLE, pack_pos=0),
etc = [StorageStyle('TRACK'),
StorageStyle('TRACKNUMBER')],
asf = StorageStyle('WM/TrackNumber'),
)
tracktotal = MediaField(out_type=int,
mp3 = StorageStyle('TRCK', packing=packing.SLASHED, pack_pos=1),
mp4 = StorageStyle('trkn', packing=packing.TUPLE, pack_pos=1),
etc = [StorageStyle('TRACKTOTAL'),
StorageStyle('TRACKC'),
StorageStyle('TOTALTRACKS')],
StorageStyle('----:com.apple.iTunes:publisher')],
etc = [StorageStyle('LABEL'),
StorageStyle('PUBLISHER')], # Traktor
asf = StorageStyle('WM/Publisher'),
)
artist_sort = MediaField(
mp3 = StorageStyle('TSOP'),
mp4 = StorageStyle("soar"),
etc = StorageStyle('ARTISTSORT'),
asf = StorageStyle('WM/ArtistSortOrder'),
)
albumartist_sort = MediaField(
mp3 = StorageStyle('TXXX', id3_desc=u'ALBUMARTISTSORT'),
mp4 = StorageStyle("soaa"),
etc = StorageStyle('ALBUMARTISTSORT'),
asf = StorageStyle('WM/AlbumArtistSortOrder'),
)
asin = MediaField(
mp3 = StorageStyle('TXXX', id3_desc=u'ASIN'),
mp4 = StorageStyle("----:com.apple.iTunes:ASIN"),
etc = StorageStyle('ASIN'),
asf = StorageStyle('MusicBrainz/ASIN'),
)
catalognum = MediaField(
mp3 = StorageStyle('TXXX', id3_desc=u'CATALOGNUMBER'),
mp4 = StorageStyle("----:com.apple.iTunes:CATALOGNUMBER"),
etc = StorageStyle('CATALOGNUMBER'),
asf = StorageStyle('WM/CatalogNo'),
)
disctitle = MediaField(
mp3 = StorageStyle('TSST'),
mp4 = StorageStyle("----:com.apple.iTunes:DISCSUBTITLE"),
date = DateField(
MP3StorageStyle('TDRC'),
MP4StorageStyle('\xa9day'),
StorageStyle('DATE'),
ASFStorageStyle('WM/Year'),
year=(StorageStyle('YEAR'),))
year = date.year_field()
month = date.month_field()
day = date.day_field()
# *Original* release date.
original_date = DateField(
MP3StorageStyle('TDOR'),
MP4StorageStyle('----:com.apple.iTunes:ORIGINAL YEAR'),
StorageStyle('ORIGINALDATE'),
ASFStorageStyle('WM/OriginalReleaseYear'))
original_year = original_date.year_field()
original_month = original_date.month_field()
original_day = original_date.day_field()
# Nonstandard metadata.
artist_credit = MediaField(
MP3DescStorageStyle(u'Artist Credit'),
MP4StorageStyle('----:com.apple.iTunes:Artist Credit'),
StorageStyle('ARTIST_CREDIT'),
ASFStorageStyle('beets/Artist Credit'),
)
albumartist_credit = MediaField(
MP3DescStorageStyle(u'Album Artist Credit'),
MP4StorageStyle('----:com.apple.iTunes:Album Artist Credit'),
mp4 = StorageStyle("\xa9cmt"),
etc = [StorageStyle('DESCRIPTION'),
StorageStyle('COMMENT')],
asf = StorageStyle('WM/Comments'),
)
bpm = MediaField(out_type=int,
mp3 = StorageStyle('TBPM'),
mp4 = StorageStyle('tmpo', as_type=int),
etc = StorageStyle('BPM'),
asf = StorageStyle('WM/BeatsPerMinute'),
)
comp = MediaField(out_type=bool,
mp3 = StorageStyle('TCMP'),
mp4 = StorageStyle('cpil', list_elem=False, as_type=bool),
etc = StorageStyle('COMPILATION'),
asf = StorageStyle('WM/IsCompilation', as_type=bool),
)
albumartist = MediaField(
mp3 = StorageStyle('TPE2'),
mp4 = StorageStyle('aART'),
etc = [StorageStyle('ALBUM ARTIST'),
StorageStyle('ALBUMARTIST')],
asf = StorageStyle('WM/AlbumArtist'),
)
albumtype = MediaField(
mp3 = StorageStyle('TXXX', id3_desc=u'MusicBrainz Album Type'),
mp4 = StorageStyle('----:com.apple.iTunes:MusicBrainz Album Type'),
etc = StorageStyle('MUSICBRAINZ_ALBUMTYPE'),
asf = StorageStyle('MusicBrainz/Album Type'),
)
label = MediaField(
mp3 = StorageStyle('TPUB'),
mp4 = StorageStyle("----:com.apple.iTunes:Album Artist Credit"),
etc = StorageStyle('ALBUMARTIST_CREDIT'),
asf = StorageStyle('beets/Album Artist Credit'),
)
# Album art.
art = ImageField()
# MusicBrainz IDs.
mb_trackid = MediaField(
mp3 = StorageStyle('UFID:http://musicbrainz.org',
list_elem = False,
id3_frame_field = 'data'),
mp4 = StorageStyle('----:com.apple.iTunes:MusicBrainz Track Id',
as_type=str),
etc = StorageStyle('MUSICBRAINZ_TRACKID'),
asf = StorageStyle('MusicBrainz/Track Id'),
)
mb_albumid = MediaField(
mp3 = StorageStyle('TXXX', id3_desc=u'MusicBrainz Album Id'),
mp4 = StorageStyle('----:com.apple.iTunes:MusicBrainz Album Id',
as_type=str),
etc = StorageStyle('MUSICBRAINZ_ALBUMID'),
asf = StorageStyle('MusicBrainz/Album Id'),
)
mb_artistid = MediaField(
mp3 = StorageStyle('TXXX', id3_desc=u'MusicBrainz Artist Id'),
mp4 = StorageStyle('----:com.apple.iTunes:MusicBrainz Artist Id',
as_type=str),
etc = StorageStyle('MUSICBRAINZ_ARTISTID'),
asf = StorageStyle('MusicBrainz/Artist Id'),
)
MP3PeopleStorageStyle('TIPL', involvement='arranger'),
MP4StorageStyle('----:com.apple.iTunes:Arranger'),
StorageStyle('ARRANGER'),
ASFStorageStyle('beets/Arranger'),
)
grouping = MediaField(
MP3StorageStyle('TIT1'),
MP4StorageStyle('\xa9grp'),
StorageStyle('GROUPING'),
ASFStorageStyle('WM/ContentGroupDescription'),
)
track = MediaField(
MP3SlashPackStorageStyle('TRCK', pack_pos=0),
MP4TupleStorageStyle('trkn', index=0),
StorageStyle('TRACK'),
StorageStyle('TRACKNUMBER'),
ASFStorageStyle('WM/TrackNumber'),
out_type=int,
)
tracktotal = MediaField(
MP3SlashPackStorageStyle('TRCK', pack_pos=1),
MP4TupleStorageStyle('trkn', index=1),
StorageStyle('TRACKTOTAL'),
StorageStyle('TRACKC'),
StorageStyle('TOTALTRACKS'),
ASFStorageStyle('TotalTracks'),
out_type=int,
)
disc = MediaField(
MP3SlashPackStorageStyle('TPOS', pack_pos=0),
MP4TupleStorageStyle('disk', index=0),
MP4StorageStyle('----:com.apple.iTunes:MusicBrainz '
'Album Release Country'),
StorageStyle('RELEASECOUNTRY'),
ASFStorageStyle('MusicBrainz/Album Release Country'),
)
albumstatus = MediaField(
MP3DescStorageStyle(u'MusicBrainz Album Status'),
MP4StorageStyle('----:com.apple.iTunes:MusicBrainz Album Status'),
StorageStyle('RELEASESTATUS'),
StorageStyle('MUSICBRAINZ_ALBUMSTATUS'),
ASFStorageStyle('MusicBrainz/Album Status'),
)
media = MediaField(
MP3StorageStyle('TMED'),
MP4StorageStyle('----:com.apple.iTunes:MEDIA'),
StorageStyle('MEDIA'),
ASFStorageStyle('WM/Media'),
)
albumdisambig = MediaField(
# This tag mapping was invented for beets (not used by Picard, etc).
MP3DescStorageStyle(u'MusicBrainz Album Comment'),
MP4StorageStyle('----:com.apple.iTunes:MusicBrainz Album Comment'),
StorageStyle('MUSICBRAINZ_ALBUMCOMMENT'),
ASFStorageStyle('MusicBrainz/Album Comment'),
)
# Release date.
date = DateField(
MP3StorageStyle('TDRC'),
MP4StorageStyle('\xa9day'),
StorageStyle('DATE'),
ASFStorageStyle('WM/Year'),
lyricist = MediaField(
MP3StorageStyle('TEXT'),
MP4StorageStyle('----:com.apple.iTunes:LYRICIST'),
StorageStyle('LYRICIST'),
ASFStorageStyle('WM/Writer'),
)
composer = MediaField(
MP3StorageStyle('TCOM'),
MP4StorageStyle('\xa9wrt'),
StorageStyle('COMPOSER'),
ASFStorageStyle('WM/Composer'),
)
composer_sort = MediaField(
MP3StorageStyle('TSOC'),
MP4StorageStyle('soco'),
StorageStyle('COMPOSERSORT'),
ASFStorageStyle('WM/Composersortorder'),
)
arranger = MediaField(
MP3PeopleStorageStyle('TIPL', involvement='arranger'),
MP4StorageStyle('----:com.apple.iTunes:Arranger'),
StorageStyle('ARRANGER'),
ASFStorageStyle('beets/Arranger'),
)
grouping = MediaField(
MP3StorageStyle('TIT1'),
MP4StorageStyle('\xa9grp'),
StorageStyle('GROUPING'),
ASFStorageStyle('WM/ContentGroupDescription'),
)
track = MediaField(