• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.Track类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mopidy.models.Track的典型用法代码示例。如果您正苦于以下问题:Python Track类的具体用法?Python Track怎么用?Python Track使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Track类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: tracks

def tracks(item, formats, uri=uri):
    identifier = item['metadata']['identifier']
    track = Track(album=album(item['metadata']))
    tracks = []
    for obj in files(item, formats):
        filename = obj.get('name')
        tracks.append(track.replace(
            uri=uri(identifier, filename),
            name=obj.get('title', filename),
            artists=artists(obj) or track.album.artists,
            genre=obj.get('genre'),
            track_no=parse_track(obj.get('track')),
            length=parse_length(obj.get('length')),
            bitrate=parse_bitrate(obj.get('bitrate')),
            last_modified=parse_mtime(obj.get('mtime'))
        ))
    return tracks
开发者ID:tkem,项目名称:mopidy-internetarchive,代码行数:17,代码来源:translator.py


示例2: test_scan

    def test_scan(self, mock_scan):
        mock_scan.return_value = {
            'tags': {
                'image': [GIF_DATA, PNG_DATA],
                'preview-image': [JPEG_DATA]
            }
        }

        album = Album(name='foo')
        track = Track(uri=b'local:track:foo.mp3', album=album)
        images = ['/images/' + name for name in GIF_NAME, PNG_NAME, JPEG_NAME]
        image_track = track.copy(album=album.copy(images=images))

        self.library.add(track)
        mock_library.add.assert_called_with(image_track, None, None)
        self.assertTrue(os.path.isfile(os.path.join(self.tempdir, GIF_NAME)))
        self.assertTrue(os.path.isfile(os.path.join(self.tempdir, PNG_NAME)))
        self.assertTrue(os.path.isfile(os.path.join(self.tempdir, JPEG_NAME)))

        self.library.close()
        self.assertEqual(os.listdir(self.tempdir), [])
开发者ID:LukeSkywalker92,项目名称:mopidy-local-images,代码行数:21,代码来源:test_library.py


示例3: setUp

    def setUp(self):  # noqa: N802
        self.tags = {
            "album": ["album"],
            "track-number": [1],
            "artist": ["artist"],
            "composer": ["composer"],
            "performer": ["performer"],
            "album-artist": ["albumartist"],
            "title": ["track"],
            "track-count": [2],
            "album-disc-number": [2],
            "album-disc-count": [3],
            "date": [datetime.date(2006, 1, 1)],
            "container-format": ["ID3 tag"],
            "genre": ["genre"],
            "comment": ["comment"],
            "musicbrainz-trackid": ["trackid"],
            "musicbrainz-albumid": ["albumid"],
            "musicbrainz-artistid": ["artistid"],
            "musicbrainz-albumartistid": ["albumartistid"],
            "bitrate": [1000],
        }

        artist = Artist(name="artist", musicbrainz_id="artistid")
        composer = Artist(name="composer")
        performer = Artist(name="performer")
        albumartist = Artist(name="albumartist", musicbrainz_id="albumartistid")

        album = Album(name="album", num_tracks=2, num_discs=3, musicbrainz_id="albumid", artists=[albumartist])

        self.track = Track(
            name="track",
            date="2006-01-01",
            genre="genre",
            track_no=1,
            disc_no=2,
            comment="comment",
            musicbrainz_id="trackid",
            album=album,
            bitrate=1000,
            artists=[artist],
            composers=[composer],
            performers=[performer],
        )
开发者ID:tylerball,项目名称:mopidy,代码行数:44,代码来源:test_utils.py


示例4: setUp

    def setUp(self):
        self.data = {
            'uri': 'uri',
            'duration': 4531000000,
            'mtime': 1234,
            'tags': {
                'album': ['album'],
                'track-number': [1],
                'artist': ['artist'],
                'composer': ['composer'],
                'performer': ['performer'],
                'album-artist': ['albumartist'],
                'title': ['track'],
                'track-count': [2],
                'album-disc-number': [2],
                'album-disc-count': [3],
                'date': [FakeGstDate(2006, 1, 1,)],
                'container-format': ['ID3 tag'],
                'genre': ['genre'],
                'comment': ['comment'],
                'musicbrainz-trackid': ['trackid'],
                'musicbrainz-albumid': ['albumid'],
                'musicbrainz-artistid': ['artistid'],
                'musicbrainz-albumartistid': ['albumartistid'],
                'bitrate': [1000],
            },
        }

        artist = Artist(name='artist', musicbrainz_id='artistid')
        composer = Artist(name='composer')
        performer = Artist(name='performer')
        albumartist = Artist(name='albumartist',
                             musicbrainz_id='albumartistid')

        album = Album(name='album', num_tracks=2, num_discs=3,
                      musicbrainz_id='albumid', artists=[albumartist])

        self.track = Track(uri='uri', name='track', date='2006-01-01',
                           genre='genre', track_no=1, disc_no=2, length=4531,
                           comment='comment', musicbrainz_id='trackid',
                           last_modified=1234, album=album, bitrate=1000,
                           artists=[artist], composers=[composer],
                           performers=[performer])
开发者ID:NilsNoreyson,项目名称:mopidy,代码行数:43,代码来源:test_scan.py


示例5: setUp

    def setUp(self):  # noqa: N802
        self.tags = {
            'album': ['album'],
            'track-number': [1],
            'artist': ['artist'],
            'composer': ['composer'],
            'performer': ['performer'],
            'album-artist': ['albumartist'],
            'title': ['track'],
            'track-count': [2],
            'album-disc-number': [2],
            'album-disc-count': [3],
            'date': ['2006-01-01'],
            'container-format': ['ID3 tag'],
            'genre': ['genre'],
            'comment': ['comment'],
            'musicbrainz-trackid': ['trackid'],
            'musicbrainz-albumid': ['albumid'],
            'musicbrainz-artistid': ['artistid'],
            'musicbrainz-sortname': ['sortname'],
            'musicbrainz-albumartistid': ['albumartistid'],
            'bitrate': [1000],
        }

        artist = Artist(name='artist', musicbrainz_id='artistid',
                        sortname='sortname')
        composer = Artist(name='composer')
        performer = Artist(name='performer')
        albumartist = Artist(name='albumartist',
                             musicbrainz_id='albumartistid')

        album = Album(name='album', date='2006-01-01',
                      num_tracks=2, num_discs=3,
                      musicbrainz_id='albumid', artists=[albumartist])

        self.track = Track(name='track',
                           genre='genre', track_no=1, disc_no=2,
                           comment='comment', musicbrainz_id='trackid',
                           album=album, bitrate=1000, artists=[artist],
                           composers=[composer], performers=[performer])
开发者ID:Afolabi28,项目名称:mopidy,代码行数:40,代码来源:test_tags.py


示例6: test_replace_track_with_private_internal_value

 def test_replace_track_with_private_internal_value(self):
     artist1 = Artist(name='foo')
     artist2 = Artist(name='bar')
     track = Track(artists=[artist1])
     other = track.replace(artists=[artist2])
     self.assertIn(artist2, other.artists)
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:6,代码来源:test_models.py


示例7: TagsToTrackTest

class TagsToTrackTest(unittest.TestCase):

    def setUp(self):  # noqa: N802
        self.tags = {
            'album': ['album'],
            'track-number': [1],
            'artist': ['artist'],
            'composer': ['composer'],
            'performer': ['performer'],
            'album-artist': ['albumartist'],
            'title': ['track'],
            'track-count': [2],
            'album-disc-number': [2],
            'album-disc-count': [3],
            'date': ['2006-01-01'],
            'container-format': ['ID3 tag'],
            'genre': ['genre'],
            'comment': ['comment'],
            'musicbrainz-trackid': ['trackid'],
            'musicbrainz-albumid': ['albumid'],
            'musicbrainz-artistid': ['artistid'],
            'musicbrainz-sortname': ['sortname'],
            'musicbrainz-albumartistid': ['albumartistid'],
            'bitrate': [1000],
        }

        artist = Artist(name='artist', musicbrainz_id='artistid',
                        sortname='sortname')
        composer = Artist(name='composer')
        performer = Artist(name='performer')
        albumartist = Artist(name='albumartist',
                             musicbrainz_id='albumartistid')

        album = Album(name='album', date='2006-01-01',
                      num_tracks=2, num_discs=3,
                      musicbrainz_id='albumid', artists=[albumartist])

        self.track = Track(name='track',
                           genre='genre', track_no=1, disc_no=2,
                           comment='comment', musicbrainz_id='trackid',
                           album=album, bitrate=1000, artists=[artist],
                           composers=[composer], performers=[performer])

    def check(self, expected):
        actual = tags.convert_tags_to_track(self.tags)
        self.assertEqual(expected, actual)

    def test_track(self):
        self.check(self.track)

    def test_missing_track_no(self):
        del self.tags['track-number']
        self.check(self.track.replace(track_no=None))

    def test_multiple_track_no(self):
        self.tags['track-number'].append(9)
        self.check(self.track)

    def test_missing_track_disc_no(self):
        del self.tags['album-disc-number']
        self.check(self.track.replace(disc_no=None))

    def test_multiple_track_disc_no(self):
        self.tags['album-disc-number'].append(9)
        self.check(self.track)

    def test_missing_track_name(self):
        del self.tags['title']
        self.check(self.track.replace(name=None))

    def test_multiple_track_name(self):
        self.tags['title'] = ['name1', 'name2']
        self.check(self.track.replace(name='name1; name2'))

    def test_missing_track_musicbrainz_id(self):
        del self.tags['musicbrainz-trackid']
        self.check(self.track.replace(musicbrainz_id=None))

    def test_multiple_track_musicbrainz_id(self):
        self.tags['musicbrainz-trackid'].append('id')
        self.check(self.track)

    def test_missing_track_bitrate(self):
        del self.tags['bitrate']
        self.check(self.track.replace(bitrate=None))

    def test_multiple_track_bitrate(self):
        self.tags['bitrate'].append(1234)
        self.check(self.track)

    def test_missing_track_genre(self):
        del self.tags['genre']
        self.check(self.track.replace(genre=None))

    def test_multiple_track_genre(self):
        self.tags['genre'] = ['genre1', 'genre2']
        self.check(self.track.replace(genre='genre1; genre2'))

    def test_missing_track_date(self):
        del self.tags['date']
#.........这里部分代码省略.........
开发者ID:Afolabi28,项目名称:mopidy,代码行数:101,代码来源:test_tags.py


示例8: test_different_instance_with_replace

 def test_different_instance_with_replace(self):
     t = Track(uri='test1')
     self.assertIsNot(t, t.replace(uri='test2'))
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:3,代码来源:test_models.py


示例9: test_replace_track_with_missing_values

 def test_replace_track_with_missing_values(self):
     track = Track(uri='bar')
     other = track.replace(name='baz')
     self.assertEqual('baz', other.name)
     self.assertEqual('bar', other.uri)
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:5,代码来源:test_models.py


示例10: test_name

 def test_name(self):
     name = 'a name'
     track = Track(name=name)
     self.assertEqual(track.name, name)
     with self.assertRaises(AttributeError):
         track.name = None
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:6,代码来源:test_models.py


示例11: test_serialize

 def test_serialize(self):
     track = Track(uri="uri", name="name")
     self.assertDictEqual(
         {"__model__": "TlTrack", "tlid": 123, "track": track.serialize()},
         TlTrack(tlid=123, track=track).serialize(),
     )
开发者ID:serman,项目名称:mopidy,代码行数:6,代码来源:models_test.py


示例12: test_copying_track_with_missing_values

 def test_copying_track_with_missing_values(self):
     track = Track(uri='bar')
     copy = track.copy(name='baz')
     self.assertEqual('baz', copy.name)
     self.assertEqual('bar', copy.uri)
开发者ID:eisnerd,项目名称:mopidy,代码行数:5,代码来源:models_test.py


示例13: test_serialize_with_tracks

 def test_serialize_with_tracks(self):
     track = Track(name='foo')
     self.assertDictEqual(
         {'__model__': 'Playlist', 'uri': 'uri', 'name': 'name',
             'tracks': [track.serialize()]},
         Playlist(uri='uri', name='name', tracks=[track]).serialize())
开发者ID:eisnerd,项目名称:mopidy,代码行数:6,代码来源:models_test.py


示例14: test_disc_no

 def test_disc_no(self):
     disc_no = 2
     track = Track(disc_no=disc_no)
     self.assertEqual(track.disc_no, disc_no)
     with self.assertRaises(AttributeError):
         track.disc_no = None
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:6,代码来源:test_models.py


示例15: test_date

 def test_date(self):
     date = '1977-01-01'
     track = Track(date=date)
     self.assertEqual(track.date, date)
     with self.assertRaises(AttributeError):
         track.date = None
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:6,代码来源:test_models.py


示例16: test_track_no

 def test_track_no(self):
     track_no = 7
     track = Track(track_no=track_no)
     self.assertEqual(track.track_no, track_no)
     with self.assertRaises(AttributeError):
         track.track_no = None
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:6,代码来源:test_models.py


示例17: test_album

 def test_album(self):
     album = Album()
     track = Track(album=album)
     self.assertEqual(track.album, album)
     with self.assertRaises(AttributeError):
         track.album = None
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:6,代码来源:test_models.py


示例18: test_performers

 def test_performers(self):
     artists = [Artist(name='name1'), Artist(name='name2')]
     track = Track(performers=artists)
     self.assertEqual(set(track.performers), set(artists))
     with self.assertRaises(AttributeError):
         track.performers = None
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:6,代码来源:test_models.py


示例19: TranslatorTest

class TranslatorTest(unittest.TestCase):
    def setUp(self):
        self.data = {
            'uri': 'uri',
            'duration': 4531000000,
            'mtime': 1234,
            'tags': {
                'album': ['album'],
                'track-number': [1],
                'artist': ['artist'],
                'composer': ['composer'],
                'performer': ['performer'],
                'album-artist': ['albumartist'],
                'title': ['track'],
                'track-count': [2],
                'album-disc-number': [2],
                'album-disc-count': [3],
                'date': [FakeGstDate(2006, 1, 1,)],
                'container-format': ['ID3 tag'],
                'genre': ['genre'],
                'comment': ['comment'],
                'musicbrainz-trackid': ['trackid'],
                'musicbrainz-albumid': ['albumid'],
                'musicbrainz-artistid': ['artistid'],
                'musicbrainz-albumartistid': ['albumartistid'],
                'bitrate': [1000],
            },
        }

        artist = Artist(name='artist', musicbrainz_id='artistid')
        composer = Artist(name='composer')
        performer = Artist(name='performer')
        albumartist = Artist(name='albumartist',
                             musicbrainz_id='albumartistid')

        album = Album(name='album', num_tracks=2, num_discs=3,
                      musicbrainz_id='albumid', artists=[albumartist])

        self.track = Track(uri='uri', name='track', date='2006-01-01',
                           genre='genre', track_no=1, disc_no=2, length=4531,
                           comment='comment', musicbrainz_id='trackid',
                           last_modified=1234, album=album, bitrate=1000,
                           artists=[artist], composers=[composer],
                           performers=[performer])

    def check(self, expected):
        actual = scan.audio_data_to_track(self.data)
        self.assertEqual(expected, actual)

    def test_track(self):
        self.check(self.track)

    def test_none_track_length(self):
        self.data['duration'] = None
        self.check(self.track.copy(length=None))

    def test_none_track_last_modified(self):
        self.data['mtime'] = None
        self.check(self.track.copy(last_modified=None))

    def test_missing_track_no(self):
        del self.data['tags']['track-number']
        self.check(self.track.copy(track_no=None))

    def test_multiple_track_no(self):
        self.data['tags']['track-number'].append(9)
        self.check(self.track)

    def test_missing_track_disc_no(self):
        del self.data['tags']['album-disc-number']
        self.check(self.track.copy(disc_no=None))

    def test_multiple_track_disc_no(self):
        self.data['tags']['album-disc-number'].append(9)
        self.check(self.track)

    def test_missing_track_name(self):
        del self.data['tags']['title']
        self.check(self.track.copy(name=None))

    def test_multiple_track_name(self):
        self.data['tags']['title'] = ['name1', 'name2']
        self.check(self.track.copy(name='name1; name2'))

    def test_missing_track_musicbrainz_id(self):
        del self.data['tags']['musicbrainz-trackid']
        self.check(self.track.copy(musicbrainz_id=None))

    def test_multiple_track_musicbrainz_id(self):
        self.data['tags']['musicbrainz-trackid'].append('id')
        self.check(self.track)

    def test_missing_track_bitrate(self):
        del self.data['tags']['bitrate']
        self.check(self.track.copy(bitrate=None))

    def test_multiple_track_bitrate(self):
        self.data['tags']['bitrate'].append(1234)
        self.check(self.track)

#.........这里部分代码省略.........
开发者ID:NilsNoreyson,项目名称:mopidy,代码行数:101,代码来源:test_scan.py


示例20: test_replace_track

 def test_replace_track(self):
     track = Track()
     self.compare(track, track.replace())
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:3,代码来源:test_models.py



注:本文中的mopidy.models.Track类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python status.status函数代码示例发布时间:2022-05-27
下一篇:
Python models.Ref类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap