kevlu8 / Reddit-to-Google-Drive

Download Reddit posts and upload to a Google Drive folder based on date

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reddit to Google Drive

Bulk download Reddit posts and upload to a Google Drive folder. This program uses PyDrive and praw

Setup

pip install -r requirements.txt

The new and improved version only needs ~10 MB of free space! 🎉

Use

Open parent.txt and modify it to your preferences. Here's the format:

Parent_ID

Parent ID:

Drive folder ID of where the files should be put. This is the ID of a folder:

image

If you want it in your My Drive, put root here.

Here's an example of a good parent.txt file:

1-1xxSMUmeZdoKwst052yTzMgcDcT-ZGC

Now, go to the Google Developer Console and create a new project.

image

Name it whatever you want then click Create.

image

Now, click on "Enable APIs and Services"

image

Search for Google Drive and enable Google Drive API

image

image

After you get redirected to this screen, click on "Create Credentials"

image

Choose these settings:

image

then click next.

Here, you can name your app whatever you want and enter your email in the 2 fields. Also pick an icon.

image

I'm using a throwaway email so there's no need to try to email me.

When it asks you for scopes, just ignore it and click continue.

In OAuth Client ID, pick these settings:

image

When you see this, click done.

image

Now, download the JSON. It will be named something really long. Just change that to client_secrets.json and move it to H:\

image

Go to "OAuth consent screen" and add yourself as a test user.

image

image

Now, go to settings.yaml and change the client_id to your client id and the client_secret to your client secret (both are in client_secrets.json)

Subreddit:

Which sub to get posts from. Do not include the r/, only include the name. For instance, pics

If left unspecified, it will get posts from all the subreddits you are in.

Post Amount:

How many posts to get. Cannot be over 1000 due to api limitations.

Keep Posts:

If you don't want to delete the images after uploading them, pass -k to the main file.

Wait for it to finish downloading. Once it finishes, it will prompt you to log in. Just select the account where you want the files to be uploaded and allow access. Then, it will upload.

Here's an example of a valid command to download 100 trending memes:

python3 main.py -s memes -n 100

What do the files do

client_secrets.json

Used to authorize the upload of the files into your Google Drive using the Google Drive API

parent.txt

Contains your settings for what you want downloaded and uploaded

main.py

Main code that will download the files, store them in a temporary folder and upload them to Google Drive

settings.yaml

Settings containing your client secret and id, also used to authorize the upload of files into your Google Drive

credentials.json

Stores credentials from previous run so you don't have to re-authenticate each time you want to download and upload

auth.json

Contains your reddit API information in order to make requests

requirements.txt

Libraries needed.

About

Download Reddit posts and upload to a Google Drive folder based on date


Languages

Language:Python 100.0%