How to use the sma.utils.is_youtube function in sma

To help you get started, we’ve selected a few sma examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sdockray / sma / sma / archiver.py View on Github external
def markdownify(self, summary=False, text_only=False, prefer_snapshot=False):
		def absurl(path):
			return files.tnurl(path)
		title_to_use = self.title if hasattr(self,'title') and self.title else self.url
		title_to_use_bracket_safe = re.sub('[\[\]\(\)]', '', title_to_use)
		title_to_use_quote_safe = re.sub('["\(\)]', '', title_to_use)
		preferred_image = self.snapshot if prefer_snapshot or not summary else self.image
		# youtube links shouldshow thumbnail, not screenshot if possible
		if utils.is_youtube(self.url):
			preferred_image = self.image
		if not preferred_image:
			if self.image:
				preferred_image = self.image
			if self.snapshot:
				preferred_image = self.snapshot
		if summary:
			output = "\n" 
			if not text_only:
				if preferred_image:
					output = "%s&gt; [ ![%s](%s \"%s\") ](%s \"%s\") <br>\n" % (output, title_to_use_bracket_safe, absurl(preferred_image), title_to_use_quote_safe, files.lurl(self.url), title_to_use_quote_safe)
			output = "%s&gt; [%s](%s \"%s\") <br>\n" % (output, title_to_use_bracket_safe, files.lurl(self.url), title_to_use_quote_safe)
			if self.summary:
				about = "%s... %s" % (self.summary, self.description)
				about = re.sub('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&amp;+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', '', about)
				about = re.sub(r'[\r\n]*', '', about)
github sdockray / sma / sma / sponge.py View on Github external
def summary(url):
	if utils.is_youtube(url):
		return summary_youtube(url)
	# all non-youtube
	summ = Summary(url)
	summ.extract()
	return (summ.title, summ.description, summ.image.url)