Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def mk_tweet(self, prefix, twitter_ids, video_name, authors, video_url):
- """
- Should return (examples):
- #lca2017 My Talk Title - @CarlFK http://youtu.be/123456
- #lca2017 My Talk Title - Carl Karsten http://youtu.be/123456
- #lca2017 My Really Long Talk Title That Got Shortened Because It Is Lon... - Carl Karsten http://youtu.be/123456
- """
- TWITTER_LENGTH_MAX = 140
- # always shorten video_url's (if not already shortened)
- if len(video_url) > 25:
- video_url = self.shorten(video_url)
- AVAILABLE_CHARS = TWITTER_LENGTH_MAX - len(prefix) - len(video_url) - 5
- message = '#{prefix} {video_name} - {authors} {video_url}'.format(
- prefix=prefix,
- video_url=video_url
- )
- if twitter_ids:
- authors = twitter_ids
- else:
- authors = authors
- if AVAILABLE_CHARS - len(video_name) - len(authors) >= 0:
- return message.format(video_name=video_name, authors=authors)
- else:
- MAX_TITLE_CHARS = AVAILABLE_CHARS - len(authors)
- shortened_video_name = video_name[:AVAILABLE_CHARS]
- return message.format(video_name=shortened_video_name, authors=authors)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement