Exemplo n.º 1
0
	def test_object_w_flashvar(self):
		res = get_metamedia_data("""<div><object type="application/x-shockwave-flash" data="http://i.dmdentertainment.com/DMVideoPlayer/player_test.swf" id="player" height="365" width="650" ><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="movie" value="http://i.dmdentertainment.com/DMVideoPlayer/player_test.swf" /><param name="flashVars" value="demand_rvdisplaymode=2&demand_iconlink=http%3A//www.cracked.com/&demand_rvthumb=http%3A%2F%2Fi-beta.crackedcdn.com%2Fphpimages%2Fimage%2F4%2F2%2F2%2F61422.jpg%3Fv%3D1&DESC=&demand_bghex=0&height=22&KEYWORDS=&TITLE=Agents+of+Cracked%3A+Taking+Office+Politics+Way+Too+Seriously&demand_rvbg=&adPartner=Adap&demand_continuous_play=1&demand_page_url=http%3A%2F%2Fwww.cracked.com%2Fvideo_18280_friendly-fire-marshal.html&demand_uihex=FFD000&demand_content_id=18280&COMPANION_DIV_ID=adaptv_ad_companion_div&demand_site_id=CRCC&demand_rvpip=0&sitename=Cracked.com&comscore_c3=7290858&demand_cat=Movies+%26+TV&demand_autoplay=0&ADPTAG=GoodNeighbor&video_title=Agents+of+Cracked%3A+Taking+Office+Politics+Way+Too+Seriously&demand_content_sourcekey=cracked.com&KEY=DemandMediacracked&skin=http%3A//i.dmdentertainment.com/DMVideoPlayer/playerskin_test.swf&demand_show_replay=true&ADAPTAG=&CATEGORIES=Movies+%26+TV&source=http%3A%2F%2Fi-beta.crackedcdn.com%2Fphpimages%2Fvideos%2F0%2F8%2F3%2F63083_608X342.flv&URL=http%3A%2F%2Fi-beta.crackedcdn.com%2Fphpimages%2Fvideos%2F0%2F8%2F3%2F63083_608X342.flv&demand_preroll=false&demand_iconurl=http%3A//i-beta.crackedcdn.com/ui/shared/images/global/icons/Video_Cracked.png&ID=18252&demand_related=1&demand_preroll_source=http%3A//i-beta.crackedcdn.com/ui/shared/resources/Pre-Roll1b_cr.swf&demand_icontext=Watch%20more%20videos%20at%20Cracked.com%20America%27s%20only%20humor%20site.&v=3.0.6.f&wa_vemb=1" /></object></div>""", 'http://media.nerdblerp.com/media/409294_300.jpg')
		self.assertEquals(len(res),2)
		self.assertEquals(len(res['meta']),3)
		self.assertEquals(len(res['link']),2)
		self.assertEquals(res['meta'].get('video_height'),"365")
		self.assertEquals(res['meta'].get('video_width'),"650")
		self.assertEquals(res['meta'].get('video_type'),"application/x-shockwave-flash")
		self.assertEquals(res['link'].get('video_src'),"http://i.dmdentertainment.com/DMVideoPlayer/player_test.swf?demand_rvdisplaymode=2&demand_iconlink=http%3A//www.cracked.com/&demand_rvthumb=http%3A%2F%2Fi-beta.crackedcdn.com%2Fphpimages%2Fimage%2F4%2F2%2F2%2F61422.jpg%3Fv%3D1&DESC=&demand_bghex=0&height=22&KEYWORDS=&TITLE=Agents+of+Cracked%3A+Taking+Office+Politics+Way+Too+Seriously&demand_rvbg=&adPartner=Adap&demand_continuous_play=1&demand_page_url=http%3A%2F%2Fwww.cracked.com%2Fvideo_18280_friendly-fire-marshal.html&demand_uihex=FFD000&demand_content_id=18280&COMPANION_DIV_ID=adaptv_ad_companion_div&demand_site_id=CRCC&demand_rvpip=0&sitename=Cracked.com&comscore_c3=7290858&demand_cat=Movies+%26+TV&demand_autoplay=0&ADPTAG=GoodNeighbor&video_title=Agents+of+Cracked%3A+Taking+Office+Politics+Way+Too+Seriously&demand_content_sourcekey=cracked.com&KEY=DemandMediacracked&skin=http%3A//i.dmdentertainment.com/DMVideoPlayer/playerskin_test.swf&demand_show_replay=true&ADAPTAG=&CATEGORIES=Movies+%26+TV&source=http%3A%2F%2Fi-beta.crackedcdn.com%2Fphpimages%2Fvideos%2F0%2F8%2F3%2F63083_608X342.flv&URL=http%3A%2F%2Fi-beta.crackedcdn.com%2Fphpimages%2Fvideos%2F0%2F8%2F3%2F63083_608X342.flv&demand_preroll=false&demand_iconurl=http%3A//i-beta.crackedcdn.com/ui/shared/images/global/icons/Video_Cracked.png&ID=18252&demand_related=1&demand_preroll_source=http%3A//i-beta.crackedcdn.com/ui/shared/resources/Pre-Roll1b_cr.swf&demand_icontext=Watch%20more%20videos%20at%20Cracked.com%20America%27s%20only%20humor%20site.&v=3.0.6.f&wa_vemb=1")
		self.assertEquals(res['link'].get('image_src'),"http://media.nerdblerp.com/media/409294_300.jpg")
Exemplo n.º 2
0
	def test_embed(self):
		res = get_metamedia_data("""<div><embed src="http://www.youtube.com/v/JW5meKfy3fY?version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390"></div>""")
		self.assertEquals(len(res),2)
		self.assertEquals(len(res['meta']),3)
		self.assertEquals(len(res['link']),2)
		self.assertEquals(res['meta'].get('video_height'),"390")
		self.assertEquals(res['meta'].get('video_width'),"640")
		self.assertEquals(res['meta'].get('video_type'),"application/x-shockwave-flash")
		self.assertEquals(res['link'].get('video_src'),"http://www.youtube.com/v/JW5meKfy3fY?version=3")
		self.assertEquals(res['link'].get('image_src'),"http://img.youtube.com/vi/JW5meKfy3fY/default.jpg")
Exemplo n.º 3
0
	def test_object_w_embed(self):
		res = get_metamedia_data("""<div><<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/MHA7EqaVbk4&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en_US&amp;feature=player_embedded&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/MHA7EqaVbk4&amp;color1=0xb1b1b1&amp;color2=0xcfcfcf&amp;hl=en_US&amp;feature=player_embedded&amp;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="425" height="344"></embed></object></div>""")
		self.assertEquals(len(res),2)
		self.assertEquals(len(res['meta']),3)
		self.assertEquals(len(res['link']),2)
		self.assertEquals(res['meta'].get('video_height'),"344")
		self.assertEquals(res['meta'].get('video_width'),"425")
		self.assertEquals(res['meta'].get('video_type'),"application/x-shockwave-flash")
		self.assertEquals(res['link'].get('video_src'),"http://www.youtube.com/v/MHA7EqaVbk4&color1=0xb1b1b1&color2=0xcfcfcf&hl=en_US&feature=player_embedded&fs=1")
		self.assertEquals(res['link'].get('image_src'),"http://img.youtube.com/vi/MHA7EqaVbk4/default.jpg")
Exemplo n.º 4
0
	def update_from_dict(self, dt, default_thumb=None):
		self.title = dt.get('title',None)
		self.published = dt.get('published',None)
		self.content = dt.get('content',None)
		self.sticky = dt.get('sticky',None)
		self.can_comment = dt.get('can_comment',None)
		self.page_id = dt.get('page_id',None)
		
		self.metacontent = html.striphtml(self.content)
		self.summary = html.stripobjects(self.content)
		media_data = html.get_metamedia_data(self.content, default_thumb)
		self.links = media_data.get('link',{})
		self.metatags = media_data.get('meta',{})
		
		self.tags.clear()
		for label in dt.get('tags',[]):
			tag = Tag.get_from_id(slugify(label)) or Tag(label=label)
			self.tags.add(tag)
		
		self.updated = rfc3339.now().replace(tzinfo=None)
Exemplo n.º 5
0
	def from_dict(cls, dt, default_thumb=None):
		item = cls()
		item.title = dt.get('title',None)
		item.published = dt.get('published',None)
		item.content = dt.get('content',None)
		item.sticky = dt.get('sticky',None)
		item.can_comment = dt.get('can_comment',None)
		item.page_id = dt.get('page_id',None)
		
		item.contributors = []
		item.metacontent = html.striphtml(item.content)
		item.summary = html.stripobjects(item.content)
		media_data = html.get_metamedia_data(item.content, default_thumb)
		item.links = media_data.get('link',{})
		item.metatags = media_data.get('meta',{})
		
		for label in dt.get('tags',[]):
			tag = Tag.get_from_id(slugify(label)) or Tag(label=label)
			item.tags.add(tag)
		item.updated = rfc3339.now().replace(tzinfo=None)
		if item.created is None:
			item.created = item.updated
		return item
Exemplo n.º 6
0
	def test_img(self):
		res = get_metamedia_data("""<div><img src="http://example.com/img.jpg"/></div>""")
		self.assertEquals(len(res),2)
		self.assertEquals(len(res['meta']),0)
		self.assertEquals(len(res['link']),1)
		self.assertEquals(res['link'].get('image_src'),"http://example.com/img.jpg")
Exemplo n.º 7
0
	def test_blank(self):
		res = get_metamedia_data(123)
		self.assertEquals(len(res),2)
		self.assertEquals(len(res['meta']),0)
		self.assertEquals(len(res['link']),0)