本文整理汇总了Python中mopidy.frontends.mpd.translator.track_to_mpd_format函数的典型用法代码示例。如果您正苦于以下问题:Python track_to_mpd_format函数的具体用法?Python track_to_mpd_format怎么用?Python track_to_mpd_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了track_to_mpd_format函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: playlistinfo
def playlistinfo(context, songpos=None, start=None, end=None):
"""
*musicpd.org, current playlist section:*
``playlistinfo [[SONGPOS] | [START:END]]``
Displays a list of all songs in the playlist, or if the optional
argument is given, displays information only for the song
``SONGPOS`` or the range of songs ``START:END``.
*ncmpc and mpc:*
- uses negative indexes, like ``playlistinfo "-1"``, to request
the entire playlist
"""
if songpos is not None:
songpos = int(songpos)
cp_track = context.backend.current_playlist.get(cpid=songpos).get()
return track_to_mpd_format(cp_track, position=songpos)
else:
if start is None:
start = 0
start = int(start)
if not (0 <= start <= context.backend.current_playlist.length.get()):
raise MpdArgError(u"Bad song index", command=u"playlistinfo")
if end is not None:
end = int(end)
if end > context.backend.current_playlist.length.get():
end = None
cp_tracks = context.backend.current_playlist.cp_tracks.get()
return tracks_to_mpd_format(cp_tracks, start, end)
开发者ID:sanyaade-webdev,项目名称:mopidy,代码行数:31,代码来源:current_playlist.py
示例2: translate
def translate(self, track):
base_path = self.media_dir.encode("utf-8")
result = dict(translator.track_to_mpd_format(track))
result["file"] = uri_to_path(result["file"])[len(base_path) + 1 :]
result["key"] = os.path.basename(result["file"])
result["mtime"] = mtime("")
return translator.order_mpd_track_info(result.items())
开发者ID:vorodev,项目名称:mopidy,代码行数:7,代码来源:translator_test.py
示例3: translate
def translate(self, track):
base_path = self.media_dir.encode('utf-8')
result = dict(translator.track_to_mpd_format(track))
result['file'] = uri_to_path(result['file'])[len(base_path) + 1:]
result['key'] = os.path.basename(result['file'])
result['mtime'] = mtime('')
return translator.order_mpd_track_info(result.items())
开发者ID:Halfnhav,项目名称:mopidy,代码行数:7,代码来源:translator_test.py
示例4: translate
def translate(self, track):
folder = settings.LOCAL_MUSIC_PATH
result = dict(translator.track_to_mpd_format(track))
result['file'] = uri_to_path(result['file'])
result['file'] = result['file'][len(folder)+1:]
result['key'] = os.path.basename(result['file'])
result['mtime'] = mtime('')
return translator.order_mpd_track_info(result.items())
开发者ID:MechanisM,项目名称:mopidy,代码行数:8,代码来源:serializer_test.py
示例5: test_track_to_mpd_format_for_empty_track
def test_track_to_mpd_format_for_empty_track(self):
result = translator.track_to_mpd_format(Track())
self.assert_(('file', '') in result)
self.assert_(('Time', 0) in result)
self.assert_(('Artist', '') in result)
self.assert_(('Title', '') in result)
self.assert_(('Album', '') in result)
self.assert_(('Track', 0) in result)
self.assert_(('Date', '') in result)
self.assertEqual(len(result), 7)
开发者ID:MechanisM,项目名称:mopidy,代码行数:10,代码来源:serializer_test.py
示例6: test_track_to_mpd_format_for_empty_track
def test_track_to_mpd_format_for_empty_track(self):
result = translator.track_to_mpd_format(Track())
self.assertIn(("file", ""), result)
self.assertIn(("Time", 0), result)
self.assertIn(("Artist", ""), result)
self.assertIn(("Title", ""), result)
self.assertIn(("Album", ""), result)
self.assertIn(("Track", 0), result)
self.assertIn(("Date", ""), result)
self.assertEqual(len(result), 7)
开发者ID:vorodev,项目名称:mopidy,代码行数:10,代码来源:translator_test.py
示例7: test_track_to_mpd_format_for_nonempty_track
def test_track_to_mpd_format_for_nonempty_track(self):
result = translator.track_to_mpd_format(TlTrack(122, self.track), position=9)
self.assertIn(("file", "a uri"), result)
self.assertIn(("Time", 137), result)
self.assertIn(("Artist", "an artist"), result)
self.assertIn(("Title", "a name"), result)
self.assertIn(("Album", "an album"), result)
self.assertIn(("AlbumArtist", "an other artist"), result)
self.assertIn(("Track", "7/13"), result)
self.assertIn(("Date", datetime.date(1977, 1, 1)), result)
self.assertIn(("Pos", 9), result)
self.assertIn(("Id", 122), result)
self.assertEqual(len(result), 10)
开发者ID:vorodev,项目名称:mopidy,代码行数:13,代码来源:translator_test.py
示例8: currentsong
def currentsong(context):
"""
*musicpd.org, status section:*
``currentsong``
Displays the song info of the current song (same song that is
identified in status).
"""
current_cp_track = context.backend.playback.current_cp_track.get()
if current_cp_track is not None:
position = context.backend.playback.current_playlist_position.get()
return track_to_mpd_format(current_cp_track, position=position)
开发者ID:Dvad,项目名称:mopidy,代码行数:13,代码来源:status.py
示例9: currentsong
def currentsong(context):
"""
*musicpd.org, status section:*
``currentsong``
Displays the song info of the current song (same song that is
identified in status).
"""
tl_track = context.core.playback.current_tl_track.get()
if tl_track is not None:
position = context.core.tracklist.index(tl_track).get()
return track_to_mpd_format(tl_track, position=position)
开发者ID:abarisain,项目名称:mopidy,代码行数:13,代码来源:status.py
示例10: test_track_to_mpd_format_for_nonempty_track
def test_track_to_mpd_format_for_nonempty_track(self):
result = translator.track_to_mpd_format(self.track, position=9, cpid=122)
self.assert_(('file', 'a uri') in result)
self.assert_(('Time', 137) in result)
self.assert_(('Artist', 'an artist') in result)
self.assert_(('Title', 'a name') in result)
self.assert_(('Album', 'an album') in result)
self.assert_(('AlbumArtist', 'an other artist') in result)
self.assert_(('Track', '7/13') in result)
self.assert_(('Date', dt.date(1977, 1, 1)) in result)
self.assert_(('Pos', 9) in result)
self.assert_(('Id', 122) in result)
self.assertEqual(len(result), 10)
开发者ID:bok,项目名称:mopidy,代码行数:13,代码来源:serializer_test.py
示例11: test_track_to_mpd_format_for_nonempty_track
def test_track_to_mpd_format_for_nonempty_track(self):
result = translator.track_to_mpd_format(
TlTrack(122, self.track), position=9)
self.assertIn(('file', 'a uri'), result)
self.assertIn(('Time', 137), result)
self.assertIn(('Artist', 'an artist'), result)
self.assertIn(('Title', 'a name'), result)
self.assertIn(('Album', 'an album'), result)
self.assertIn(('AlbumArtist', 'an other artist'), result)
self.assertIn(('Track', '7/13'), result)
self.assertIn(('Date', datetime.date(1977, 1, 1)), result)
self.assertIn(('Pos', 9), result)
self.assertIn(('Id', 122), result)
self.assertEqual(len(result), 10)
开发者ID:Halfnhav,项目名称:mopidy,代码行数:14,代码来源:translator_test.py
示例12: playlistid
def playlistid(context, cpid=None):
"""
*musicpd.org, current playlist section:*
``playlistid {SONGID}``
Displays a list of songs in the playlist. ``SONGID`` is optional
and specifies a single song to display info for.
"""
if cpid is not None:
try:
cpid = int(cpid)
cp_track = context.backend.current_playlist.get(cpid=cpid).get()
position = context.backend.current_playlist.index(cp_track).get()
return track_to_mpd_format(cp_track, position=position)
except LookupError:
raise MpdNoExistError(u"No such song", command=u"playlistid")
else:
return tracks_to_mpd_format(context.backend.current_playlist.cp_tracks.get())
开发者ID:sanyaade-webdev,项目名称:mopidy,代码行数:19,代码来源:current_playlist.py
示例13: playlistfind
def playlistfind(context, tag, needle):
"""
*musicpd.org, current playlist section:*
``playlistfind {TAG} {NEEDLE}``
Finds songs in the current playlist with strict matching.
*GMPC:*
- does not add quotes around the tag.
"""
if tag == 'filename':
tl_tracks = context.core.tracklist.filter(uri=needle).get()
if not tl_tracks:
return None
position = context.core.tracklist.index(tl_tracks[0]).get()
return translator.track_to_mpd_format(tl_tracks[0], position=position)
raise MpdNotImplemented # TODO
开发者ID:0xadam,项目名称:mopidy,代码行数:19,代码来源:current_playlist.py
示例14: playlistid
def playlistid(context, tlid=None):
"""
*musicpd.org, current playlist section:*
``playlistid {SONGID}``
Displays a list of songs in the playlist. ``SONGID`` is optional
and specifies a single song to display info for.
"""
if tlid is not None:
tlid = int(tlid)
tl_tracks = context.core.tracklist.filter(tlid=tlid).get()
if not tl_tracks:
raise MpdNoExistError('No such song', command='playlistid')
position = context.core.tracklist.index(tl_tracks[0]).get()
return translator.track_to_mpd_format(tl_tracks[0], position=position)
else:
return translator.tracks_to_mpd_format(
context.core.tracklist.tl_tracks.get())
开发者ID:0xadam,项目名称:mopidy,代码行数:19,代码来源:current_playlist.py
示例15: playlistfind
def playlistfind(context, tag, needle):
"""
*musicpd.org, current playlist section:*
``playlistfind {TAG} {NEEDLE}``
Finds songs in the current playlist with strict matching.
*GMPC:*
- does not add quotes around the tag.
"""
if tag == "filename":
try:
cp_track = context.backend.current_playlist.get(uri=needle).get()
position = context.backend.current_playlist.index(cp_track).get()
return track_to_mpd_format(cp_track, position=position)
except LookupError:
return None
raise MpdNotImplemented # TODO
开发者ID:sanyaade-webdev,项目名称:mopidy,代码行数:20,代码来源:current_playlist.py
示例16: test_track_to_mpd_format_musicbrainz_albumid
def test_track_to_mpd_format_musicbrainz_albumid(self):
album = self.track.album.copy(musicbrainz_id='foo')
track = self.track.copy(album=album)
result = translator.track_to_mpd_format(track)
self.assert_(('MUSICBRAINZ_ALBUMID', 'foo') in result)
开发者ID:MechanisM,项目名称:mopidy,代码行数:5,代码来源:serializer_test.py
示例17: test_track_to_mpd_format_musicbrainz_trackid
def test_track_to_mpd_format_musicbrainz_trackid(self):
track = self.track.copy(musicbrainz_id='foo')
result = translator.track_to_mpd_format(track)
self.assert_(('MUSICBRAINZ_TRACKID', 'foo') in result)
开发者ID:MechanisM,项目名称:mopidy,代码行数:4,代码来源:serializer_test.py
示例18: test_track_to_mpd_format_with_position_and_cpid
def test_track_to_mpd_format_with_position_and_cpid(self):
result = translator.track_to_mpd_format(Track(), position=1, cpid=2)
self.assert_(('Pos', 1) in result)
self.assert_(('Id', 2) in result)
开发者ID:MechanisM,项目名称:mopidy,代码行数:4,代码来源:serializer_test.py
示例19: test_track_to_mpd_format_with_cpid
def test_track_to_mpd_format_with_cpid(self):
result = translator.track_to_mpd_format(Track(), cpid=1)
self.assert_(('Id', 1) not in result)
开发者ID:MechanisM,项目名称:mopidy,代码行数:3,代码来源:serializer_test.py
示例20: test_track_to_mpd_format_with_position
def test_track_to_mpd_format_with_position(self):
result = translator.track_to_mpd_format(Track(), position=1)
self.assert_(('Pos', 1) not in result)
开发者ID:MechanisM,项目名称:mopidy,代码行数:3,代码来源:serializer_test.py
注:本文中的mopidy.frontends.mpd.translator.track_to_mpd_format函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论