Skip to content

About

Any scripts I've written to extend Ghost functionality for Joel+

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Joel Kalich's Scripts for Ghost

Scripts for extending Ghost functionality on Joel+.

LLMs were used to assist in the creation of these scripts. I have tested them and they seem to work well on my Ghost instance.

Configuration

Both scripts are configured via a .env file placed next to them (not via editing the scripts themselves).

  1. Copy .env.example to .env.
  2. Fill in the values — .env.example documents every variable, which script uses it, and what it does.
  3. Run either script. It automatically loads .env from its own directory before doing anything else, and will exit with an error naming any required variable that's still unset.

.env is gitignored, so your Ghost admin key and PeerTube credentials never get committed.

There's no separate script/state directory to configure — each script writes its seen-id file (and --test/cron output goes wherever you redirect it) next to itself, wherever you've placed it.

crosspost-youtube-posts.sh

Checks YouTube for new Community posts and cross-posts them to Ghost.

Features

  • Supports --test mode:
    • Creates draft Ghost posts instead of public ones.
    • Does not add the YouTube post ID to the seen-posts file.
  • Supports --init mode:
    • Creates the seen posts file.
    • Populates file with existing YouTube posts.
    • Does not make any draft or public posts to Ghost at all.
  • Stores seen YouTube post IDs in a text file to prevent duplicate posts.
  • Detects the YouTube post type and reflects it in the Ghost post title.
  • Tags Ghost posts with a specified tag.
  • Uses the first line of the YouTube post text as the Ghost subtitle.
  • Embeds the YouTube post as a Ghost bookmark card.
  • Extracts the first YouTube post image and uses it as the Ghost feature image.
  • Notifies Ghost members via email by publishing a draft, then changing the post to published.

Known limitations

  • It does not fully replicate YouTube Community posts inside Ghost.
    • Polls, quizzes, and other interactive post types would be silly to replicate, so instead it just links to YouTube.
    • The logic could likely be updated to replicate text posts and image posts, and link to YouTube for interactive posts, but that is not implemented.

Setup

Fill in .env (see Configuration above)

  1. Set YOUTUBE_CHANNEL_ID.
    • This is not your (for example) @JoelKalich handle, it's a unique ID generated by YouTube.
    • Use a YouTube channel ID finder if needed.
  2. Set GHOST_URL to your Ghost instance URL.
  3. Create a Ghost Admin API key:
    • Ghost Admin → Settings → Integrations → Custom Integrations → Add Custom Integration
    • Copy the Admin API key into GHOST_ADMIN_KEY.
  4. Set GHOST_NEWSLETTER_SLUG.
    • If you use the default newsletter, the default value may already work.
    • You can verify this by poking around in the F12 inspector while editing the newsletter setting in the admin settings, looking for the newsletter slug.
  5. Set YOUTUBE_GHOST_TAG if you want it to be different from the default.
  6. Set YOUTUBE_GHOST_VISIBILITY if you want the cross-posted Ghost posts to be something other than public (e.g. members or paid).
  7. Update the bookmark card URLs (YOUTUBE_BOOKMARK_ICON / YOUTUBE_BOOKMARK_THUMBNAIL).
    • Icon: YouTube logo (included in repo)
    • Thumbnail: default image if post is not an image post.
    • You can probably generate these automatically by manually creating a draft post with a /bookmark card of an existing YouTube text post, then inspecting the element and copying the URLs of the images.

Initialize and Test the script

  1. Run the script in --init mode to populate post IDs.
  2. Create a new YouTube community post (or edit the seen post file to remove one of the posts).
  3. Run the script in --test mode to ensure it makes a draft post to your Ghost instance.
  4. Add a cron job to run the script automatically. I haven't had any issues with having it run every minute.

peertube-non-main-video-update-post.sh

Checks PeerTube instance for new videos from specified channels, makes a playlist containing those videos in chronological order, and creates a ghost post with that playlist embedded.

Features

  • Supports --test mode:
    • Creates a draft Ghost post instead of public ones.
    • Does not add the PeerTube post ID to the seen-posts file.
  • Supports --init mode:
    • Creates the seen posts file.
    • Populates file with existing PeerTube posts.
    • Does not make any draft or public posts to Ghost at all.
  • Stores seen PeerTube post IDs in a text file to prevent duplicate posts.
  • Tags Ghost posts with a specified tag.
  • Creates a PeerTube playlist automatically.
  • Embeds PeerTube playlist in ghost post.
  • Notifies Ghost members via email by publishing a draft, then changing the post to published.

Known limitations

  • None at the moment.

Setup

Fill in .env (see Configuration above)

  1. Set PEERTUBE_URL to your PeerTube instance URL.
  2. Set PEERTUBE_CHANNELS to the comma-separated channels you'd like to scan for new videos.
  3. Set PEERTUBE_USERNAME and PEERTUBE_PASSWORD.
  4. Set PEERTUBE_PLAYLIST_CHANNEL_ID.
  5. Set GHOST_URL to your Ghost instance URL.
  6. Create a Ghost Admin API key:
    • Ghost Admin → Settings → Integrations → Custom Integrations → Add Custom Integration
    • Copy the Admin API key into GHOST_ADMIN_KEY.
  7. Set GHOST_NEWSLETTER_SLUG.
    • If you use the default newsletter, the default value may already work.
    • You can verify this by poking around in the F12 inspector while editing the newsletter setting in the admin settings, looking for the newsletter slug.
  8. Set PEERTUBE_GHOST_TAG if you want it to be different from the default.
  9. Other variables in .env.example (playlist naming, fetch count, live-skipping, email segment, link ref) can be left at their defaults or customized.
  10. To change the post itself beyond what .env covers, edit the script. ctrl+f for Sunday Sidecar to find the section that builds the ghost post, as this is what I titled my weekly post.

Initialize and Test the script

  1. Run the script in --init mode to populate post IDs.
  2. Upload a new peertube video to one of the watched channels (or edit the seen post file to remove one of the posts).
  3. Run the script in --test mode to ensure it makes a draft post to your Ghost instance.
  4. Add a cron job to run the script automatically.

About

Any scripts I've written to extend Ghost functionality for Joel+

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages