Skip to content

Instantly share code, notes, and snippets.

@kirkins
Created September 3, 2017 19:16
Show Gist options
  • Save kirkins/7d9dcafb6d3d725c9a8bf3e359f79334 to your computer and use it in GitHub Desktop.
Save kirkins/7d9dcafb6d3d725c9a8bf3e359f79334 to your computer and use it in GitHub Desktop.
A script that downloads banned youtube videos shared by a twitter user
#!/usr/bin/env python
#
# A python that fetches the 200 latest tweets from a user
# then downloads any youtube video linked to.
#
# User can be changed with the variable below
user="YoutubeSandbox"
import re
import twitter
import youtube_dl
api = twitter.Api(consumer_key='',
consumer_secret='',
access_token_key='',
access_token_secret='')
statuses = api.GetUserTimeline(screen_name=user, count=200)
for s in statuses:
ydl_opts = {'outtmpl':'./video/%(title)s-%(id)s.%(ext)s'}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([re.search("(?P<url>https?://[^\s]+)", s.text).group("url")])
@kirkins
Copy link
Author

kirkins commented Sep 3, 2017

Banned-from-youtube-downloader

A script that downloads banned youtube videos shared by a twitter user

Setup

Get twitter app credentials at apps.twitter.com, fill them out in get.py:

api = twitter.Api(consumer_key='',                                        
  consumer_secret='',                                     
  access_token_key='',                                    
  access_token_secret='')

Install requirments with pip:

pip install youtube-dl python-twitter

Optional, change source user for downloads:

user="YoutubeSandbox"

Run Script

After setup run with:

python get.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment