本文整理汇总了Python中miro.playlist.SavedPlaylist.add_item方法的典型用法代码示例。如果您正苦于以下问题:Python SavedPlaylist.add_item方法的具体用法?Python SavedPlaylist.add_item怎么用?Python SavedPlaylist.add_item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类miro.playlist.SavedPlaylist
的用法示例。
在下文中一共展示了SavedPlaylist.add_item方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_callbacks
# 需要导入模块: from miro.playlist import SavedPlaylist [as 别名]
# 或者: from miro.playlist.SavedPlaylist import add_item [as 别名]
def test_callbacks(self):
initialList = [self.i1, self.i2, self.i3]
playlist = SavedPlaylist(u"rocketboom", [i.id for i in initialList])
tracker = Item.playlist_view(playlist.id).make_tracker()
tracker.connect('added', self.add_callback)
tracker.connect('removed', self.remove_callback)
playlist.add_item(self.i4)
self.check_callbacks([self.i4], [])
playlist.remove_item(self.i3)
self.check_callbacks([self.i4], [self.i3])
示例2: test_basic_operations
# 需要导入模块: from miro.playlist import SavedPlaylist [as 别名]
# 或者: from miro.playlist.SavedPlaylist import add_item [as 别名]
def test_basic_operations(self):
playlist = SavedPlaylist(u"rocketboom")
self.assertEquals(playlist.get_title(), u'rocketboom')
self.check_list(playlist, [])
playlist.add_item(self.i4)
playlist.add_item(self.i1)
playlist.add_item(self.i3)
playlist.add_item(self.i2)
self.check_list(playlist, [self.i4, self.i1, self.i3, self.i2])
playlist.add_item(self.i2)
self.check_list(playlist, [self.i4, self.i1, self.i3, self.i2])
self.assert_(self.i1.keep)
self.assert_(self.i2.keep)
self.assert_(self.i3.keep)
self.assert_(self.i4.keep)
playlist.remove_item(self.i2)
self.check_list(playlist, [self.i4, self.i1, self.i3])
playlist.reorder([self.i3.id, self.i4.id, self.i1.id])
self.check_list(playlist, [self.i3, self.i4, self.i1])
playlist.remove_item(self.i3)
self.check_list(playlist, [self.i4, self.i1])
示例3: PlaylistItemTrackTest
# 需要导入模块: from miro.playlist import SavedPlaylist [as 别名]
# 或者: from miro.playlist.SavedPlaylist import add_item [as 别名]
class PlaylistItemTrackTest(TrackerTest):
def setUp(self):
TrackerTest.setUp(self)
self.items = []
self.feed = Feed(u'dtv:manualFeed')
self.playlist = SavedPlaylist(u'test playlist')
self.make_item(u'http://example.com/')
self.make_item(u'http://example.com/2')
self.runUrgentCalls()
messages.TrackItems('playlist', self.playlist.id).send_to_backend()
self.runUrgentCalls()
def make_item(self, url):
entry = _build_entry(url, 'video/x-unknown')
item_ = Item(FeedParserValues(entry), feed_id=self.feed.id)
self.items.append(item_)
self.playlist.add_item(item_)
def checkDownloadInfo(self, info, item):
downloader = item.downloader
self.assertEquals(info.current_size, downloader.get_current_size())
self.assertEquals(info.rate, downloader.get_rate())
self.assertEquals(info.state, downloader.get_state())
def check_info(self, itemInfo, item):
self.assertEquals(itemInfo.name, item.get_title())
self.assertEquals(itemInfo.description, item.get_description())
self.assertEquals(itemInfo.release_date, item.get_release_date())
self.assertEquals(itemInfo.size, item.get_size())
self.assertEquals(itemInfo.permalink, item.get_link())
self.assertEquals(itemInfo.id, item.id)
self.assertEquals(itemInfo.expiration_date, item.get_expiration_time())
self.assertEquals(itemInfo.thumbnail, item.get_thumbnail())
if item.downloader:
self.checkDownloadInfo(itemInfo.download_info)
else:
self.assertEquals(itemInfo.download_info, None)
def check_changed_message_type(self, message):
self.assertEquals(type(message), messages.ItemsChanged)
self.assertEquals(message.type, 'playlist')
def test_initial_list(self):
self.assertEquals(len(self.test_handler.messages), 1)
message = self.test_handler.messages[0]
self.assert_(isinstance(message, messages.ItemList))
self.assertEquals(message.type, 'playlist')
self.assertEquals(message.id, self.playlist.id)
self.assertEquals(len(message.items), len(self.items))
message.items.sort(key=lambda i: i.id)
self.check_info_list(message.items, self.items)
def test_update(self):
self.items[0].entry_title = u'new name'
self.items[0].signal_change()
self.runUrgentCalls()
self.assertEquals(len(self.test_handler.messages), 2)
self.check_changed_message(1, changed=[self.items[0]])
def test_add(self):
self.make_item(u'http://example.com/3')
self.make_item(u'http://example.com/4')
self.make_item(u'http://example.com/5')
self.runUrgentCalls()
self.assertEquals(len(self.test_handler.messages), 2)
self.check_changed_message(1, added=self.items[2:])
def test_remove(self):
self.items[1].remove()
self.runUrgentCalls()
self.assertEquals(len(self.test_handler.messages), 2)
self.check_changed_message(1, removed=[self.items[1]])
def test_stop(self):
messages.StopTrackingItems(
'playlist', self.playlist.id).send_to_backend()
self.runUrgentCalls()
self.items[0].entry_title = u'new name'
self.items[0].signal_change()
self.items[1].remove()
self.make_item(u'http://example.com/4')
self.runUrgentCalls()
self.assertEquals(len(self.test_handler.messages), 1)