Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

Automate social media posts

The background

A part of our workflow at Abandoned Hope is:

  1. Post YouTube video with custom thumbnail, video title and description
  2. Share this on all social media (Twitter, Facebook and IGTV) manually

This takes our certain time which can be automated without errors which we often commit while copy pasting cross platforms. This inspired me to write this script to automate (at least) Twitter's part for now.

How this works

Using YouTube's API calls, this will fetch metadata from the latest video including video title, high-res thumbnail and the description and post a tweet with a picture and link to YouTube's video. In our videos, we separate the last line of the video description as the hashtags (as most of us) making it easier to scrape them using regex: hashtags = re.split("\n", description)[-1]

Pre-reqs

  1. Google developer account with API keys
  2. Twitter developer account with API keys

Installation

  1. The Google APIs Client Library for Python:
pip install --upgrade google-api-python-client
pip install --upgrade google-auth-oauthlib google-auth-httplib2
  1. Tweepy API for twitter:
pip install tweepy
  1. Clone this repo:
git clone https://github.com/shreyasgaonkar/social-media-posts.git
  1. Rename config.sample.json to config.json
  2. Update config.json with your developer keys from Twitter and YouTube:
{
    "youtube_API_key": "XXXX",
    "twitter_API_Key": "XXXX",
    "twitter_secret_key": "XXXX",
    "twitter_bearer_token": "XXXX",
    "twitter_access_token": "XXXX",
    "twitter_access_token_secret": "XXXX"
}
  1. Run python app.py to post thumbail image from your latest video

Issues

If you run into this error: AttributeError: 'Http' object has no attribute 'http' , refer to the solution here: https://github.com/googleapis/google-api-python-client/issues/1046

Customize tweet

Replace this section from app.py to what fits your use-case and Twitter's character count:

# Custom status message
status = f"{title}\n\nNew Video out now! \n\n {video_url} \n\n {hashtags}"

Output:

Sample Tweet

Missing Info / Bugs

  • 😰 Something broken? Open an issue with additional context and I'll try to fix it. Screenshots help!

  • More additional services/use-cases, open a new issue

About

Automate tweeting after posting new YouTube video

Topics

Resources

Releases

No releases published

Packages

No packages published

Languages