Exemplo n.º 1
0
 def testGetYoutubeVideos(self):
     videos=get_youtube_videos(q='"funny cat"',max_results=2)
     self.assertEqual(len(videos),2)
     video=videos[1]
     self.assertIsNotNone(video['embed_url'])
     self.assertIsNotNone(video['description'])
     self.assertIsNotNone(video['author'])
     self.assertIsNotNone(video['title'])
     self.assertIsNotNone(video['embed_url_autoplay'])
     self.assertIsNotNone(video['link'])
     self.assertIsNotNone(video['id'])
     self.assertIsNotNone(video['thumbnail480x360'])
     self.assertIsNotNone(video['thumbnail90x120'])
     self.assertIsNotNone(video['published'])
     self.assertIn('funny cat',(video['title']+video['description']).lower())
Exemplo n.º 2
0
 def testGetYoutubeVideosParse(self):
     videos=get_youtube_videos(videos_json=YOUTUBE_TEST_JSON_DATA)
     self.assertEqual(len(videos),2)
     self.assertEqual(videos[0]['embed_url'],u'https://www.youtube.com/v/IyLnwCYFG8I?version=3&f=videos&app=youtube_gdata')
     self.assertEqual(videos[0]['description'],u'www.facebook.com \u05d7"\u05db \u05d3\u05d1 \u05d7\u05e0\u05d9\u05df \u05e0\u05d5\u05d0\u05dd \u05d1\u05de\u05dc\u05d9\u05d0\u05d4 \u05dc\u05e4\u05e0\u05d9 \u05d4\u05d0\u05d9\u05e9\u05d5\u05e8 \u05d4\u05e1\u05d5\u05e4\u05d9 \u05e9\u05dc \u05d7\u05d5\u05e7 \u05d4\u05d7\u05e8\u05dd - \u05d4\u05d5\u05d0 \u05d7\u05d5\u05e7 \u05d4\u05d2\u05e0\u05ea \u05d4\u05d4\u05ea\u05e0\u05d7\u05dc\u05d5\u05d9\u05d5\u05ea, \u05d9\u05d5\u05dd \u05e9\u05e0\u05d9, \u05d4-11 \u05d1\u05d9\u05d5\u05dc\u05d9 2011')
     self.assertEqual(videos[0]['author'],u'DovKhenin')
     self.assertEqual(videos[0]['title'],u'\u05d7"\u05db \u05d3\u05d1 \u05d7\u05e0\u05d9\u05df \u05e2\u05dc \u05d7\u05d5\u05e7 \u05d4\u05d7\u05e8\u05dd \u05d1\u05de\u05dc\u05d9\u05d0\u05ea \u05d4\u05db\u05e0\u05e1\u05ea')
     self.assertEqual(videos[0]['embed_url_autoplay'],u'https://www.youtube.com/v/IyLnwCYFG8I?version=3&f=videos&app=youtube_gdata&autoplay=1')
     self.assertEqual(videos[0]['link'],u'https://www.youtube.com/watch?v=IyLnwCYFG8I&feature=youtube_gdata')
     self.assertEqual(videos[0]['id'],u'http://gdata.youtube.com/feeds/api/videos/IyLnwCYFG8I')
     self.assertEqual(videos[0]['thumbnail480x360'],u'http://i.ytimg.com/vi/IyLnwCYFG8I/0.jpg')
     self.assertEqual(videos[0]['published'],datetime.datetime(2011, 7, 11, 18, 11, 18, tzinfo=tzutc()))
     self.assertEqual(videos[0]['thumbnail90x120'],"http://i.ytimg.com/vi/IyLnwCYFG8I/1.jpg")
     self.assertEqual(videos[1]['embed_url'], u'https://www.youtube.com/v/PaaEToi3wHE?version=3&f=videos&app=youtube_gdata')
     self.assertEqual(videos[1]['description'], u'\u05d7"\u05db \u05d3\u05d1 \u05d7\u05e0\u05d9\u05df \u05d1\u05e8\u05d0\u05d9\u05d5\u05df \u05d1\u05e1\u05d5\u05d2\u05e8\u05d9\u05dd \u05d7\u05e9\u05d1\u05d5\u05df, \u05d1\u05e2\u05e7\u05d1\u05d5\u05ea \u05d4\u05d4\u05e4\u05d2\u05e0\u05d4 \u05d1\u05e9\u05d1\u05ea: \u05e2\u05dc \u05e4\u05ea\u05e8\u05d5\u05e0\u05d5\u05ea \u05d0\u05e4\u05e9\u05e8\u05d9\u05d9\u05dd \u05dc\u05de\u05e6\u05d5\u05e7\u05ea \u05d4\u05d3\u05d9\u05d5\u05e8, \u05e7\u05e4\u05d9\u05d8\u05dc\u05d9\u05d6\u05dd \u05de\u05d5\u05dc \u05de\u05d3\u05d9\u05e0\u05ea \u05e8\u05d5\u05d5\u05d7\u05d4, \u05d5\u05de\u05db\u05dc\u05d5\u05dc \u05d4\u05d3\u05d1\u05e8\u05d9\u05dd \u05d1\u05d4\u05dd \u05e2\u05d5\u05e1\u05e7\u05ea \u05d4\u05de\u05d7\u05d0\u05d4 - \u05de\u05e2\u05d1\u05e8 \u05dc\u05e9\u05db\u05e8 \u05d4\u05d3\u05d9\u05e8\u05d4')
     self.assertEqual(videos[1]['author'], u'23tv')
     self.assertEqual(videos[1]['title'], u'\u05d7"\u05db \u05d3\u05d1 \u05d7\u05e0\u05d9\u05df: "\u05d4\u05e4\u05ea\u05e8\u05d5\u05df \u05d4\u05d9\u05d7\u05d9\u05d3 - \u05d4\u05d7\u05d6\u05e8\u05ea \u05d4\u05d3\u05d9\u05d5\u05e8 \u05d4\u05e6\u05d9\u05d1\u05d5\u05e8\u05d9"')
     self.assertEqual(videos[1]['embed_url_autoplay'], u'https://www.youtube.com/v/PaaEToi3wHE?version=3&f=videos&app=youtube_gdata&autoplay=1')
     self.assertEqual(videos[1]['link'], u'https://www.youtube.com/watch?v=PaaEToi3wHE&feature=youtube_gdata')
     self.assertEqual(videos[1]['id'], u'http://gdata.youtube.com/feeds/api/videos/PaaEToi3wHE')
     self.assertEqual(videos[1]['thumbnail480x360'], u'http://i.ytimg.com/vi/PaaEToi3wHE/0.jpg')
     self.assertEqual(videos[1]['published'],datetime.datetime(2011, 7, 25, 13, 11, 47, tzinfo=tzutc()))
     self.assertEqual(videos[1]['thumbnail90x120'],"http://i.ytimg.com/vi/PaaEToi3wHE/1.jpg")