本文整理汇总了Python中song.Song类的典型用法代码示例。如果您正苦于以下问题:Python Song类的具体用法?Python Song怎么用?Python Song使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Song类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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)
示例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()
示例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)
示例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)
示例7: main
def main():
"""
Main function
"""
nbt = Song()
for fpath in nbt.userpl():
sys.stdout.write("%s\n" % (fpath))
示例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)
示例9: main
def main():
"""
Main function
"""
nbt = Song()
fname = nbt.next()
#trigger(fname, "/tmp/calorine.socket")
return fname
示例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()
示例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]]")
示例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)
示例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()
示例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)
示例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))