Skip to content

Turn your YouTube videos into well-written Medium blog posts with this automation script (made with lots of love). Writes a delightful and professional article from a given full YouTube channel.

License

Notifications You must be signed in to change notification settings

pH-7/youtube-to-medium-blog-posts-automation

Repository files navigation

📝 YouTube to Medium Automation

⚡️ The Game-Changer Script You Will Always Be Grateful For!

Automate the process of converting YouTube video content into Medium articles 🎥📝

This program not only converts video transcripts extremely well into beautiful, SEO-optimized articles with images and captions, but also removes any "transcript-like" writing. It produces a real, professional article from a video instead.

Automation: Convert videos into articles

⚙️ Requirements

  • Python v3.7 or higher 🐍
  • A Google account with YouTube API access 🎬
  • An OpenAI API key 🧠
  • A Medium account with an integration token ✍️

📦 Installation

  1. Clone this repository:

    git clone https://github.com/pH-7/youtube-to-medium-blog-posts-automation.git
    cd youtube-to-medium-blog-posts-automation
  2. Install the required Python packages:

    pip install -r requirements.txt
  3. Set up your configuration file:

    • Create a file named config.json in the project root directory

    • Add your API keys and YouTube channel ID to the file as followed:

      {
        "MEDIUM_ACCESS_TOKEN": "YOUR_MEDIUM_ACCESS_TOKEN",
        "MEDIUM_EN_PUBLICATION_ID": "OPTIONAL_ENGLISH_PUBLICATION_ID",
        "MEDIUM_FR_PUBLICATION_ID": "OPTIONAL_FRENCH_PUBLICATION_ID",
        "POST_TO_PUBLICATION": true,
        "YOUTUBE_API_KEY": "YOUR_YOUTUBE_API_KEY",
        "YOUTUBE_CHANNEL_ID": "YOUR_CHANNEL_ID",
        "OPENAI_API_KEY": "YOUR_OPENAI_API_KEY",
        "OPENAI_MODEL": "gpt-4o-mini",
        "UNSPLASH_ACCESS_KEY": "YOUR_UNSPLASH_KEY",
        "UNSPLASH_PREFERRED_PHOTOGRAPHER": "pierrehenry", // Optional. Mention a preferred Unsplash photographer (e.g. pierrehenry)
        "PUBLISH_STATUS": "draft", // "draft" or "publish"
        "SOURCE_LANGUAGE": "en",
        "OUTPUT_LANGUAGE": "en"
      }

      Alternatively, you can refer to example.config.json in the project.

  4. Set up YouTube API credentials:

    • Go to the Google Developers Console
    • Create a new project and enable the YouTube Data API v3
    • Create credentials (OAuth 2.0 Client ID) for a desktop application. Select External for Use Type
    • Download the client configuration and save it as client_secrets.json in the project root directory
  5. Lastly, get your Unsplash API key: https://unsplash.com/oauth/applications/new

🪄 Usage

To run the script, use the following command in the project root directory:

python transform-youtube-videos-to-medium-posts.py

The script will:

  1. Fetch recent videos from your YouTube channel
  2. Transcribe each video
  3. Generate an exceptional well-written article for each video transcript
  4. Create 5 most relevant tags for the article
  5. Generate an engaging article title
  6. Fetch relevant images from Unsplash for the article (one for article header, and 1-2 for content)
  7. Embed a few images in the article content using Medium-compatible Markdown format.
  8. Post the article to Medium as a draft
  9. Save the generated article locally as a Markdown file, so you always keep a copy, with article's details in a markdown yaml-like metadata
  10. Clearly mentioning any issues for each publishing step till the end, right in the terminal
  11. Automatically wait a few minutes (for each iteration) before publishing a new article to Medium, to prevent being wrongly flagged as spam
  12. Sit and relax. Enjoy the work!

Note: The script posts articles as drafts by default. To change this, modify the PUBLISH_STATUS to "publish" in the config.json file.

🙃 Enjoying this project? Offer me a coffee (spoiler alert: I love almond flat white 😋)

Script running, converting YouTube videos to Medium articles

🛠️ Configuration

You can modify the following in the script:

  • The number of videos to process (change maxResults in get_channel_videos function)
  • The length of the generated article (change max_tokens in generate_article function)
  • The number of tags to generate (modify the prompt in generate_tags function)

🎬 Demo

See the script in action with these demonstration videos:

Articles conversion in French language

generating-french-blog-post-medium-articles-output-from-youyube-video-transcripts.mp4

Article conversion from English videos

demo-turn-videos-to-medium-posts.mp4

👨‍🍳 Who created this awesome script?

Pierre-Henry Soria

Pierre-Henry Soria. A super passionate engineer who loves automating efficiently content creation! 🚀 Enthusiast for YouTube, AI, learning, and writing of course! 😊 Find me at pH7.me 💫

☕️ Enjoying this project? Offer me a coffee (spoiler alert: I love almond flat white 😋)

@phenrysay YouTube Tech Videos pH-7

🤝 Contributing

Contributions to this project are welcome! Please fork the repository and submit a pull request with your changes.

⚠️ Disclaimer

Please keep in mind that this Videos to (Medium) Posts Converter project is for educational purposes only. Ensure you always comply with YouTube's terms of service and Medium's API usage guidelines and policy when using this script.

⚖️ License

YouTube to Medium Automation script is generously distributed under the MIT License 🎉 Enjoy!