• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An automation process to convert YouTube video into audio file and uploading it to Anchor.fm podcast

YouTube to Anchor.fm - An automation tool to publish your podcast

Cover image

This action will upload an audio file from a given YouTube video automatically to your Anchor.fm account.

It is very useful in a scenario where you have a YouTube account and also a podcast at Spotify through Anchor.fm.

In our live show (Schrodinger Hat) we had this necessity. So we built it for the open source community.

Every contribution is appreciated, even just a simple feedback.

Table of Contents

How it works

The action will start every time you push a change on the episode.json file. Into this file you need to specify the YouTube id of your video.

The action uses a docker image built over Ubuntu. It takes some time to setup the environment before running the script.

NOTE: For the script to run successfully its necessary for there to be at least one episode manually published on Anchor.fm, as the steps to publish on a brand new Anchor.fm account are different, and the automation will break.

How can I run this as a GitHub action?

You can use the latest version of this action from the GitHub Actions marketplace.

In the repository root directory add a episode.json file containing your YouTube video id, e.g.:

{
  "id": "nHCXZC2InAA"
}

Then create a GitHub action in the .github/workflows directory with this yaml:

name: 'Upload Episode from YouTube To Anchor.Fm'

on:
  push:
    paths:
      - episode.json
    branches: [main]

jobs:
  upload_episode:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Upload Episode from YouTube To Anchor.Fm
        uses: Schrodinger-Hat/[email protected]
        env:
          ANCHOR_EMAIL: ${{ secrets.ANCHOR_EMAIL }}
          ANCHOR_PASSWORD: ${{ secrets.ANCHOR_PASSWORD }}
          EPISODE_PATH: /github/workspace

NOTE: you need to set up the secrets for ANCHOR_EMAIL and ANCHOR_PASSWORD. This environment variables are mandatory as they specify the sign in account.

Environment variables

Draft Mode

By setting the SAVE_AS_DRAFT, the new episode will be published as a draft. This can be useful if you need someone else's approval before actual publication.

env:
  SAVE_AS_DRAFT: true

Audio conversion options

ffmpeg is used to convert the video to MP3. It's possible to pass arguments to ffmpeg with POSTPROCESSOR_ARGS environment variable.

See -postprocessor-args syntax and options on https://github.com/yt-dlp/yt-dlp#post-processing-options.

The example below convert the video to mono audio.

env:
  POSTPROCESSOR_ARGS: 'ffmpeg:-ac 1'

Explicit Mode

By setting the IS_EXPLICIT, the new episode will be marked as explicit.

env:
  IS_EXPLICIT: true

Thumbnail Mode

By setting the LOAD_THUMBNAIL, the new episode will include the video thumbnail as the episode art.

env:
  LOAD_THUMBNAIL: true

Add YouTube URL to Podcast Description

By setting the URL_IN_DESCRIPTION, the Podcast description will include the YouTube URL on a new line at the end of the description. It is recommended to set it, for if the YouTube video has no description it will fail to save the new episode. Setting it to true guarantees to always have a description.

env:
  URL_IN_DESCRIPTION: true

Set a publish date for the episode

By setting SET_PUBLISH_DATE, the new episode can be scheduled for publishing the episode on the date that the YouTube video is uploaded. Please note that the scheduling will work if SAVE_AS_DRAFT is not set, because Anchor.fm doesn't store publish date for draft episodes. If SET_PUBLISH_DATE is not set, then Anchor.fm will choose the current date for publishing.

env:
  SET_PUBLISH_DATE: true

How can I setup for development and use the script locally?

To run the script locally, you need python3 and ffmpeg to be available in PATH which are used by the npm dependency youtube-dl-exec.

Clone the repository and run npm ci to install the exact dependencies that are specified in package-lock.json.

After that, you can edit episode.json that is located at the root of this repository. It is recommended to specify the id of a short YouTube video in episode.json for testing.

Then, make sure to setup your .env file in the root of this repository so you can put the environment variables that you normally specify in the GitHub action YAML file.

To do that, you can copy .env.sample into a file with name .env.

Make sure to specify the mandatory environment variables for logging in to Anchor.fm, ANCHOR_EMAIL and ANCHOR_PASSWORD.

Finally, you can do npm start to execute the script.

How to upload a YouTube playlist to Anchor.fm using this script?

โš  WARNING: This Potentially violates GitHub's Terms of service โš 

In particular, any repositories that use GitHub Actions or similar 3rd party services solely to interact with 3rd party websites, to engage in incentivized activities, or for general computing purposes may fall foul of the GitHub Additional Product Terms (Actions), or the GitHub Acceptable Use Policies. Actions should not be used for any activity unrelated to the production, testing, deployment, or publication of the software project associated with the repository where GitHub Actions are used.

Currently, you can process a full playlist (one way only) with

curl https://scc-youtube.vercel.app/playlist-items/PLoXdlLuaGN8ShASxcE2A4YuSto3AblDmX \
    | jq '.[].contentDetails.videoId' -r \
    | tac \
    | xargs -I% bash -c "jo id='%' > episode.json && git commit -am % && git push"

https://scc-youtube.vercel.app/playlist-items is from https://github.com/ThatGuySam/youtube-json-server

jo is a json generator https://github.com/jpmens/jo

tac is a command present in most Linux distributions and on mac with brew install coreutils. Its from reversing the list from older to newer. Remove if you want to upload in the order presented on YouTube.

jq is a json processor https://stedolan.github.io/jq/

This must be run on the folder where your episode.json is.

Contributors

Thanks goes to these wonderful people (emoji key):

GabrielePuliti
GabrielePuliti

๐ŸŽจ ๐Ÿ’ป ๐Ÿšง ๐Ÿ‘€
Miki Lombardi
Miki Lombardi

๐Ÿ’ป ๐Ÿšง ๐Ÿ‘€
Abe Hanoka
Abe Hanoka

๐Ÿ’ป ๐Ÿšง ๐Ÿ‘€
matevskial
matevskial

๐Ÿ’ป ๐Ÿšง
Amod Deshpande
Amod Deshpande

๐Ÿ“–
Guilherme Costa
Guilherme Costa

๐Ÿ’ป ๐Ÿ›
Welton Rodrigo Torres Nascimento
Welton Rodrigo Torres Nascimento

๐Ÿ“– ๐Ÿ’ป
Nicola Puppa
Nicola Puppa

๐Ÿ“–
Matt
Matt

๐Ÿ›

This project follows the all-contributors specification.

License

MIT

More Repositories

1

ImageGoNord

A tool that can convert your rgb images to nordtheme palette
Vue
837
star
2

ImageGoNord-pip

A tool that can convert your rgb images to nordtheme palette
Python
164
star
3

osday

Open Source Day: Come join us and discover Open Source in the most inclusive way :)
TypeScript
34
star
4

Daje

Stop using install.sh! Start using install.yml! DAJE...
Go
27
star
5

open-source-wrapped

Don't we just love Spotify Wrapped? Well, here's the same concept applied to Open Source on Github :3
TypeScript
23
star
6

netflix-show-generator

A tool for generating Netflix show image
Vue
21
star
7

snackjob

Do you have already a snack job?
JavaScript
13
star
8

soundpad

A sound pad to bring the sound fx on the live stream
HTML
12
star
9

schrodinger-hat-website

Schrรถdinger Hat Website
TypeScript
11
star
10

loremclipsum

A CLI tool to copy-paste different Ipsums from your terminal
Rust
9
star
11

kannon

โœ‰๏ธ Cloud-Native massive mail sender for Kubernetes!
Go
9
star
12

community

Schrรถdinger Hat community content
8
star
13

ImageGoNord-cli

A python client used for ImageGoNord
Python
8
star
14

cattp

A CLI tool to understand HTTP codes and cats
Rust
7
star
15

sh-sessions

6
star
16

peoplez

Peoplez is an open-source, self-hosted organisation management software that allows you to manage basic needs of your nonprofit organisation
TypeScript
6
star
17

sh-website-cms

CMS for the Website
Vue
4
star
18

sh-nuxt-template

An opinionated Nuxt3 starter by Schrรถdinger Hat
TypeScript
4
star
19

xmas-crystal-ball-threejs

A Xmas 2020 easter egg with some crystal ball made in Three.js
JavaScript
3
star
20

sh_mobile_app

WIP
C++
1
star
21

Fred

Go
1
star