Esempio n. 1
0
 def _verify_related_video(self, video, name):
     if validate_dict(video, ['title', 'description']):
         titledesc = video['title'] + video['description']
         if (validate_dict(video, [
                 'embed_url_autoplay', 'thumbnail90x120', 'id', 'link',
                 'published'
         ]) and name in titledesc and video['published'] is not None):
             return True
         else:
             return False
     else:
         return False
 def _verify_related_video(self,video,name):
     if validate_dict(video,['title','description']):
         titledesc=video['title']+video['description']
         if (
             validate_dict(video,['embed_url_autoplay','thumbnail90x120','id','link','published'])
             and name in titledesc
             and video['published'] is not None
         ):
             return True
         else:
             return False
     else:
         return False
Esempio n. 3
0
 def testValidateDict(self):
     h={'id':{'$t':'test','type':'text'},'tmp':'xxx'}
     self.assertTrue(validate_dict('test','test'))
     self.assertTrue(validate_dict(h,['id','tmp']))
     self.assertTrue(validate_dict(h,{'id':['$t']}))
     self.assertTrue(validate_dict(h,{'id':{'$t':'test'}}))
     self.assertTrue(validate_dict(h,{'id':{'type':'text','$t':'test'}},['tmp']))
     self.assertFalse(validate_dict(h,['id','tmp','xxx']))
     self.assertFalse(validate_dict(h,{'id':['x']}))
     self.assertFalse(validate_dict(h,{'id':{'$t':'xxx'}}))
     self.assertFalse(validate_dict(h,{'id':{'$t':'test','type':'text2'}}))
     h={'published':None}
     self.assertFalse(validate_dict(h,['published']))
Esempio n. 4
0
 def _fetchSourceVideosOrderedByPublishedDesc(self,member):
     videos=[]
     for name in member.names:
         for video in self._fetchSourceVideos(name):
             if validate_dict(video,['published']):
                 videos.append(video)
     return sorted(videos,key=lambda video: video['published'], reverse=True)
 def _fetchSourceVideosOrderedByPublishedDesc(self, member):
     videos = []
     for name in member.names:
         for video in self._fetchSourceVideos(name):
             if validate_dict(video, ['published']):
                 videos.append(video)
     return sorted(videos,
                   key=lambda video: video['published'],
                   reverse=True)
Esempio n. 6
0
 def _validateYoutubeVideo(self, video):
     return validate_dict(video, [
         'embed_url_autoplay',
         'thumbnail480x360',
         'thumbnail90x120',
         'title',
         'description',
         'link',
         'id',
         'published',
     ])
Esempio n. 7
0
 def _validateYoutubeVideo(self,video):
     return validate_dict(video,[
         'embed_url_autoplay',
         'thumbnail480x360',
         'thumbnail90x120',
         'title',
         'description',
         'link',
         'id',
         'published',
     ])
Esempio n. 8
0
 def testValidateDict(self):
     h = {'id': {'$t': 'test', 'type': 'text'}, 'tmp': 'xxx'}
     self.assertTrue(validate_dict('test', 'test'))
     self.assertTrue(validate_dict(h, ['id', 'tmp']))
     self.assertTrue(validate_dict(h, {'id': ['$t']}))
     self.assertTrue(validate_dict(h, {'id': {'$t': 'test'}}))
     self.assertTrue(
         validate_dict(h, {'id': {
             'type': 'text',
             '$t': 'test'
         }}, ['tmp']))
     self.assertFalse(validate_dict(h, ['id', 'tmp', 'xxx']))
     self.assertFalse(validate_dict(h, {'id': ['x']}))
     self.assertFalse(validate_dict(h, {'id': {'$t': 'xxx'}}))
     self.assertFalse(
         validate_dict(h, {'id': {
             '$t': 'test',
             'type': 'text2'
         }}))
     h = {'published': None}
     self.assertFalse(validate_dict(h, ['published']))
 def _isValidSourceVideo(self, video, member):
     ans = False
     if validate_dict(video, [
             'title', 'embed_url_autoplay', 'thumbnail480x360', 'id',
             'description', 'link', 'published'
     ]):
         titledesc = video['title'] + video['description']
         if (u'כרטיס ביקור' in titledesc and u'ערוץ הכנסת' in titledesc):
             for name in member.names:
                 if name in titledesc:
                     ans = True
                     break
     return ans
Esempio n. 10
0
 def _isValidSourceVideo(self,video,member):
     ans=False
     if validate_dict(video,[
         'title','embed_url_autoplay','thumbnail480x360',
         'id','description','link','published'
     ]):
         title=video['title']
         if (
             u'כרטיס ביקור' in title
             and u'ערוץ הכנסת' in title
         ):
             for name in member.names:
                 if name in title:
                     ans=True
                     break
     return ans