Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ef get_youtube_title(uri, auth_key):
- vid = None
- if 'youtu.be/' not in uri:
- if '?v=' in uri:
- vid = uri[uri.index('?v=')+3:uri.index('?v=') + 14]
- elif '&v=' in uri:
- vid = uri[uri.index('&v=')+3:uri.index('&v=') + 14]
- else:
- return None
- else:
- vid = uri[uri.rindex('be/')+3:uri.rindex('be/')+14]
- video_data = query(vid, auth_key)
- if video_data is None:
- return None
- else:
- title, views, time, uploader, likes, dislikes = video_data
- if title == '':
- return None
- percentage = get_percentage(likes, dislikes)
- # Not including the uploader in the title info; it's rarely important in determining a link's quality.
- return "\002You\00300,04Tube\017 " + title + " - " + views + " views - Uploaded by " + uploader + " - " + time + "long - " + likes + " likes - " + dislikes + " dislikes - " + percentage + "%"
Advertisement
Add Comment
Please, Sign In to add comment