Example #1
0
class TestDMPlaylist(unittest.TestCase):

	def setUp(self):
		self.playlist = DMPlaylist()
		cate_game = self.playlist.appendCategory("The Game of Thorn")
		cate_game.appendItem("001", "file:///videos/001.rm", "645")
		cate_game.appendItem("002", "file:///videos/002.rm")
		self.playlist.appendItem("The Big Bang Theory",
			"file:///videos/tbbt001.mkv");
		self.playlist.appendItem("The game of thorn 002");

	def tearDown(self):
		pass

	def testWriteTo(self):
		self.playlist.writeTo("testWriteTo.dmpl")
		with open("testWriteTo.dmpl") as writeTo:
			with open("testReadFrom.dmpl") as readFrom:
				self.assertEqual(writeTo.read(), readFrom.read())

	def testReadFrom(self):
		playlist = DMPlaylist.readFrom("testReadFrom.dmpl")
		playlist.writeTo("testReadFrom2.dmpl")
		with open("testReadFrom.dmpl") as readFrom:
			with open("testReadFrom2.dmpl") as readFrom2:
				self.assertEqual(readFrom.read(), readFrom2.read())
Example #2
0
class TestDMPlaylist(unittest.TestCase):
    def setUp(self):
        self.playlist = DMPlaylist()
        cate_game = self.playlist.appendCategory("The Game of Thorn")
        cate_game.appendItem("001", "file:///videos/001.rm", "645")
        cate_game.appendItem("002", "file:///videos/002.rm")
        self.playlist.appendItem("The Big Bang Theory",
                                 "file:///videos/tbbt001.mkv")
        self.playlist.appendItem("The game of thorn 002")

    def tearDown(self):
        pass

    def testWriteTo(self):
        self.playlist.writeTo("testWriteTo.dmpl")
        with open("testWriteTo.dmpl") as writeTo:
            with open("testReadFrom.dmpl") as readFrom:
                self.assertEqual(writeTo.read(), readFrom.read())

    def testReadFrom(self):
        playlist = DMPlaylist.readFrom("testReadFrom.dmpl")
        playlist.writeTo("testReadFrom2.dmpl")
        with open("testReadFrom.dmpl") as readFrom:
            with open("testReadFrom2.dmpl") as readFrom2:
                self.assertEqual(readFrom.read(), readFrom2.read())
Example #3
0
    def exportPlaylist(self, filename):
        playlist = DMPlaylist()
        playlistItems = json.loads(self.playlist_local)

        for item in playlistItems:
            try:
                itemChild = json.loads(item["itemChild"])
                if len(itemChild) != 0 and item["itemUrl"] == "":
                    cate = playlist.appendCategory(
                        item["itemName"].encode("utf-8"))
                    for child in itemChild:
                        cate.appendItem(child["itemName"].encode("utf-8"),
                            child["itemUrl"].encode("utf-8"),
                            str(self.fetch_video_position(child["itemUrl"])))
                else:
                    playlist.appendItem(item["itemName"].encode("utf-8"),
                        item["itemUrl"].encode("utf-8"),
                        str(self.fetch_video_position(item["itemUrl"])))
            except Exception, e:
                print e