本文整理汇总了Python中song.Song类的典型用法代码示例。如果您正苦于以下问题:Python Song类的具体用法?Python Song怎么用?Python Song使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Song类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: search
def search(query):
result = api.search_all_access('lil dicky')['song_hits'][0]['track']
s = Song(result['title'], result['artist'], result['album'])
s.add_gmusic_id(result['nid'])
s.add_gmusic_video_id(result['primaryVideo']['id'])
return s
开发者ID:nrubin,项目名称:SongBabel,代码行数:7,代码来源:gmusic_api.py
示例2: get_song_by_track
def get_song_by_track(self, track_num):
tracks = self._get_track_list()
song_num = tracks[track_num]
song_id = 'song_{:02x}'.format(song_num)
song = Song(song_id)
song.set_controller(self._controller)
return song
开发者ID:cyberixae,项目名称:kunquat,代码行数:7,代码来源:album.py
示例3: SongTests
class SongTests(unittest.TestCase):
def setUp(self):
self.test_song = Song(
"Hells Bells",
"ACDC",
"Back in Black",
5,
312,
320
)
def test_song_init(self):
self.assertEqual(self.test_song.title, "Hells Bells")
self.assertEqual(self.test_song.artist, "ACDC")
self.assertEqual(self.test_song.album, "Back in Black")
self.assertEqual(self.test_song.rating, 5)
self.assertEqual(self.test_song.length, 312)
self.assertEqual(self.test_song.bitrate, 320)
def test_song_rate(self):
self.test_song.rate(3)
self.assertEqual(self.test_song.rating, 3)
def test_song_rate_out_of_range(self):
with self.assertRaises(ValueError):
self.test_song.rate(8)
开发者ID:Legena,项目名称:HackBulgaria,代码行数:26,代码来源:song_tests.py
示例4: __init__
def __init__(self, *args, **kwargs):
# set addon object
self.m_addon = kwargs["addon"]
# passing "<windowId>" from RunScript() means run in background
self.use_gui = kwargs["gui"]
# initialize our super classes
XBMCPlayer.__init__(self)
Properties.__init__(self)
# initialize timers
self._lyric_timer = None
self._fetch_timer = None
# log started action
self._log_addon_action("started")
# initialize our Song class
self.song = Song(addon=self.m_addon)
# initialize our prefetched Song class
# TODO: remove the self.isPlayingAudio() check when/if XBMC supports offset for player
self.prefetched_song = None
if (self.m_addon.getSetting("prefetch_lyrics") and self.isPlayingAudio()):
self.prefetched_song = Song(addon=self.m_addon, prefetch=True)
# start
if (self.use_gui):
self._start_gui()
else:
self._start_background()
开发者ID:nuka1195,项目名称:lyrics.xbmc_lyrics,代码行数:25,代码来源:player.py
示例5: SongTests
class SongTests(unittest.TestCase):
def setUp(self):
self.song = Song("The Jack", "ACDC", "T.N.T.", 4, 240, 320)
def test_init(self):
song = Song("The Jack", "ACDC", "T.N.T.", 4, 240, 320)
self.assertEqual(song.title, "The Jack")
self.assertEqual(song.artist, "ACDC")
self.assertEqual(song.album, "T.N.T.")
self.assertEqual(song.rating, 4)
self.assertEqual(song.length, 240)
self.assertEqual(song.bitrate, 320)
def test_rate_value_error(self):
with self.assertRaises(ValueError):
self.song.rate(6)
def test_rate_success(self):
self.song.rate(3)
self.assertEqual(self.song.rating, 3)
def test_str(self):
expected = "ACDC The Jack - 0:04:00"
self.assertEqual(str(self.song), expected)
开发者ID:antonpetkoff,项目名称:Programming101,代码行数:25,代码来源:song_test.py
示例6: TestSong
class TestSong(unittest.TestCase):
def setUp(self):
self.song = Song(
"Whole Lotta Love",
"Led Zeppelin",
"Led Zeppelin II",
5,
334,
320000
)
def test_song_init(self):
self.assertEqual(self.song.title, "Whole Lotta Love")
self.assertEqual(self.song.artist, "Led Zeppelin")
self.assertEqual(self.song.album, "Led Zeppelin II")
self.assertEqual(self.song.rating, 5)
self.assertEqual(self.song.length, 334)
self.assertEqual(self.song.bitrate, 320000)
def test_rate(self):
self.song.rate(4)
self.assertEqual(self.song.rating, 4)
def test_rate_error(self):
with self.assertRaises(ValueError):
self.song.rate(200000)
开发者ID:stoilov,项目名称:Programming101,代码行数:27,代码来源:song_test.py
示例7: main
def main():
"""
Main function
"""
nbt = Song()
for fpath in nbt.userpl():
sys.stdout.write("%s\n" % (fpath))
开发者ID:rodo,项目名称:calorine,代码行数:7,代码来源:userpl.py
示例8: TestSong
class TestSong(unittest.TestCase):
def setUp(self):
self.test_song = Song(
'Hells Bells',
'AC/DC',
'rough and though',
5,
520,
256)
def test_song_init(self):
self.assertEqual(self.test_song.title, 'Hells Bells')
self.assertEqual(self.test_song.artist, 'AC/DC')
self.assertEqual(self.test_song.album, 'rough and though')
self.assertEqual(self.test_song.rating, 5)
self.assertEqual(self.test_song.lenght, 520)
self.assertEqual(self.test_song.bitrate, 256)
def test_rating(self):
self.test_song.set_rating(4)
self.assertEqual(self.test_song.rating, 4)
def test_rating_out_of_range(self):
with self.assertRaises(ValueError):
self.test_song.set_rating(8)
开发者ID:IvanAlexandrov,项目名称:HackBulgaria-Tasks,代码行数:26,代码来源:test_song.py
示例9: main
def main():
"""
Main function
"""
nbt = Song()
fname = nbt.next()
#trigger(fname, "/tmp/calorine.socket")
return fname
开发者ID:rodo,项目名称:calorine,代码行数:8,代码来源:playlist.py
示例10: choose_file_and_convert
def choose_file_and_convert(self):
filename = WinFile(False).run()
if filename and common.file_is_supported(filename):
tags = {"uri" : utils.get_uri_from_path(filename)}
s = Song()
s.init_from_dict(tags)
s.read_from_file()
AttributesUI([s]).show_window()
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:8,代码来源:instance.py
示例11: test_tune_notation
def test_tune_notation(self):
song = Song(lyrics="hi")
notation = song.tune_notation()
self.assertRegexpMatches(notation, "[[inpt TUNE]]")
self.assertRegexpMatches(notation, "1AY {D 435; P")
self.assertRegexpMatches(notation, "hh {D 65; P")
self.assertRegexpMatches(notation, "[[inpt TEXT]]")
开发者ID:dannysullivan,项目名称:songer,代码行数:9,代码来源:test_song.py
示例12: load
def load(self, root):
for dirpath, dirnames, filenames in os.walk(root, followlinks=True):
for name in filenames:
if not name.endswith(".txt"):
continue
path = os.path.join(dirpath, name)
print path
song = Song(path)
song.id = len(self.songs)
self.songs.append(song)
开发者ID:UIKit0,项目名称:blitzloop,代码行数:10,代码来源:songlist.py
示例13: test_add_search_results
def test_add_search_results(self):
print "testing if chosen search result is added correctly"
text = "wonderwall"
results = spotify.search(text, limit = 10, type = 'track')
title = results['tracks']['items'][0]['name']
artist = results['tracks']['items'][0]['artists'][0]['name']
uri = results['tracks']['items'][0]['uri']
song1 = Song(1, title, artist, uri)
assert 'Wonderwall' in song1.getTitle()
assert 'Oasis' in song1.getArtist()
开发者ID:EvanJRichter,项目名称:PartyFy,代码行数:10,代码来源:hello_tests.py
示例14: load
def load(self):
objs = utils.load_db(self.db_file)
songs = []
if objs:
for obj in objs:
s = Song()
s.init_from_dict(obj, cmp_key="sid")
songs.append(s)
if songs:
self.add_songs(songs)
开发者ID:binyuj,项目名称:dmusic-plugin-baidumusic,代码行数:10,代码来源:music_view.py
示例15: TestSong
class TestSong(unittest.TestCase):
def setUp(self):
self.song = Song("Sweet Child O'mine", "Guns N' Roses", "Appetite for Destruction", 5, 356, 320 )
def test_rate_0(self):
self.song.rate(5)
self.assertEqual(5,self.song.rating)
def test_rate_error(self):
self.assertRaises(ValueError, lambda:self.song.rate(6))
开发者ID:dsspasov,项目名称:HackBulgaria,代码行数:10,代码来源:song_test.py
示例16: post_mount_cb
def post_mount_cb(self, track_infos, device_path, udi):
track_tags, cd_label = track_infos
if len(track_tags) > 0:
songs = []
for tag in track_tags:
cd_song = Song()
cd_song.init_from_dict(tag)
cd_song.set_type("cdda")
songs.append(cd_song)
Dispatcher.new_audiocd_playlist(cd_label, songs, udi)
self.audiocd_items[udi] = songs
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:11,代码来源:audiocd.py
示例17: create_song
def create_song(self, tags):
# Set dirty flag.
self.set_dirty()
s = Song()
s.init_from_dict(tags)
s.set_type(self.__type)
self.add(s)
return s
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:11,代码来源:webcast_library.py
示例18: search
def search(query):
escaped_query = urllib.quote(query)
base_url = "https://www.googleapis.com/youtube/v3/search?type=video&order=relevance&part=snippet&key=" + youtube_api_key + "&q="
search_string = base_url + escaped_query
r = requests.get(search_string)
first_result = r.json()['items'][0]
title = first_result['snippet']['title']
song_id = first_result['id']['videoId']
s = Song(title,None, None)
s.add_youtube_id(song_id)
return s
开发者ID:nrubin,项目名称:SongBabel,代码行数:11,代码来源:youtube_api.py
示例19: compose
def compose():
s = Song()
# choose a style
s.style = Song.styles[randint(0, len(Song.styles)-1)]
# choose a mood
s.mood = Song.moods[randint(0, len(Song.moods)-1)]
# generate a song arrangement
s.arrangement = genArrangement()
开发者ID:thejoshwolfe,项目名称:PyComposer,代码行数:11,代码来源:composer.py
示例20: decode_song
def decode_song(self, one_song):
title = one_song["title"]
artist = one_song["artist"]
album = one_song["album"]
rating = one_song["rating"]
length = one_song["length"]
bitrate = one_song["bitrate"]
file_path = one_song["file_path"]
created_song = Song(title, artist, album, rating, length, bitrate)
created_song.file_path = file_path
return created_song
开发者ID:VictorVangelov,项目名称:HackBulgaria,代码行数:11,代码来源:playlist.py
注:本文中的song.Song类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论