GithubHelp home page GithubHelp logo

duozokker / reddit2json Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 33 KB

Utilize ChatGPT or DeepL to seamlessly transform Reddit posts into tailored JSON format, personalized to the user's preferred language or desired form factor.

License: GNU General Public License v3.0

Python 100.00%
reddit reels shorts tiktok

reddit2json's Introduction

reddit2json

reddit2json is a Python script designed to process a list of Reddit post URLs, converting them into a JSON format. The script offers additional functionalities, including the ability to translate the content of Reddit posts using DeepL, and the capability to modify the content through custom OpenAI GPT calls.

Table of Contents

Installation

  1. Clone the repository:
git clone https://github.com/duozokker/reddit2json.git
  1. Navigate to the project directory:
cd reddit2json
  1. Install the required Python packages:
pip install -r requirements.txt
  1. Rename example.env to .env and fill in your API keys and other settings.

Setting up the .env file

1. Setting up the Reddit app

1.1. First, you will need to get some credentials from Reddit. These values are:

  • REDDIT_CLIENT_ID
  • REDDIT_CLIENT_SECRET
  • REDDIT_USERNAME

You can get these values from here.

1.2. Note that you need to be logged in to your Reddit account. This account cannot be a Google account or any other social login. It must be a Reddit account with a username and password. The next step will be the most essential in this entire section. Avoid any errors here!

1.3. Head over to this page. Once you are here, you should scroll down and click a button saying create another app... (it could be different if it's your first app). Once you click it, you should see:

Create Application

  • Name: you can put in any name, for example: reddit-bot
  • Radio Buttons: where it shows you the three radio buttons, pick the third one (script).
  • Description: put in anything, it does not matter.
  • About URL: link any webpage like https://google.com.
  • Redirect URI: link any webpage like https://google.com.

1.4. Great, you created the app! Now you need to give the values to the bot.

App Credentials

The text under "personal use script" is your REDDIT_CLIENT_ID, the text right next to SECRET is your REDDIT_CLIENT_SECRET (DO NOT SHARE THIS WITH ANYONE).

The text where it says developers is your REDDIT_USERNAME, and REDDIT_PASSWORD is your Reddit account's password. Your information is not logged.

Once you got all your values fill them in into the .env file that should now be looking like the following:

REDDIT_USER_AGENT= value ✅
REDDIT_CLIENT_ID= value ✅
REDDIT_CLIENT_SECRET= value ✅

DEEPL_AUTH_KEY=

OPENAI_API_KEY=

Content adapted from Reddit Video Maker Bot Documentation

2. Setting up the OpenAI Key

2.1. To get your OpenAI key, you need to sign up on the OpenAI website. After signing up, you can find your API key in the API section of the OpenAI Dashboard.

2.2. Once you have your OpenAI API key, enter it into the .env file:

REDDIT_USER_AGENT= value ✅
REDDIT_CLIENT_ID= value ✅
REDDIT_CLIENT_SECRET= value ✅

DEEPL_AUTH_KEY= 

OPENAI_API_KEY= value ✅

3. Setting up the DeepL Key

3.1. To get your DeepL key, you need to create a free account on the DeepL website. After creating an account, you can find your API key in your account settings under the "Plan & API" section.

3.2. Once you have your DeepL API key, enter it into the .env file:

REDDIT_USER_AGENT= value ✅
REDDIT_CLIENT_ID= value ✅
REDDIT_CLIENT_SECRET= value ✅

DEEPL_AUTH_KEY= value ✅

OPENAI_API_KEY= value ✅

Replace value ✅ with the respective values you received from Reddit, OpenAI and DeepL respectively.

Example Calls

To use the reddit2json.py script, you need to pass the method you want to use for processing text. The script supports two methods: translate and chat.

Here are some example calls:

  1. To process Reddit posts using the translate method:
python reddit2json.py --method translate

This will translate the content of Reddit posts to german using DeepL.

  1. To process Reddit posts using the chat method:
python reddit2json.py --method chat

This will modify the content of Reddit posts using OpenAI GPT-3.5 Turbo.

  1. To translate the content of Reddit posts to a specific language using the translate method:
python reddit2json.py --method translate --lang ES

This will translate the content of Reddit posts to Spanish using DeepL.

Note: The script reads Reddit post URLs from the reddit-post.txt file and generates a single JSON file (video.json) containing the processed content of all the posts.

Example Files

  • example-reddit-post.txt: This file contains an example of a Reddit post that can be processed by the script.
  • example-video.json: This file shows the JSON output format of the script.

License

This project is licensed under the terms of the LICENSE file.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

reddit2json's People

Contributors

duozokker avatar

Stargazers

 avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.