Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(*): update the name from anchor.fm to spotify #127

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 23 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# YouTube to Anchor.fm - An automation tool to publish your podcast
# Y2S = YouTube to Spotify - An automation tool to publish your podcast

![Cover image](https://raw.githubusercontent.com/schroedinger-Hat/youtube-to-anchorfm/main/assets/img/cover.png 'Cover image')

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

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

Expand All @@ -13,7 +13,7 @@ Every contribution is appreciated, even just a simple feedback.
Table of Contents
=================

* [YouTube to Anchor.fm - An automation tool to publish your podcast](#youtube-to-anchorfm---an-automation-tool-to-publish-your-podcast)
* [YouTube to spotify - An automation tool to publish your podcast](#youtube-to-spotify---an-automation-tool-to-publish-your-podcast)
* [How it works](#how-it-works)
* [How can I run this as a GitHub action?](#how-can-i-run-this-as-a-github-action)
* [Environment variables](#environment-variables)
Expand All @@ -25,7 +25,7 @@ Table of Contents
* [Set a publish date for the episode](#set-a-publish-date-for-the-episode)
* [Multiple shows per repository](#multiple-shows-per-repository)
* [How can I setup for development and use the script locally?](#how-can-i-setup-for-development-and-use-the-script-locally)
* [How to upload a YouTube playlist to Anchor.fm using this script?](#how-to-upload-a-youtube-playlist-to-anchorfm-using-this-script)
* [How to upload a YouTube playlist to spotify using this script?](#how-to-upload-a-youtube-playlist-to-spotify-using-this-script)
* [Contributors](#contributors)
* [License](#license)

Expand All @@ -36,11 +36,11 @@ The action will start every time you push a change on the `episode.json` file. I

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 it is 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.
**NOTE**: For the script to run successfully it is necessary for there to be at least one episode manually published on spotify, as the steps to publish on a brand new spotify 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](https://github.com/marketplace/actions/upload-episode-from-youtube-to-anchor-fm).
You can use the latest version of this action from the [GitHub Actions marketplace](https://github.com/marketplace/actions/upload-episode-from-youtube-to-spotify).

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

Expand All @@ -53,7 +53,7 @@ In the repository root directory add a `episode.json` file containing your YouTu
Then create a GitHub action in the `.github/workflows` directory with this yaml:

```yaml
name: 'Upload Episode from YouTube To Anchor.Fm'
name: 'Upload Episode from YouTube To Spotify'

on:
push:
Expand All @@ -66,30 +66,30 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Upload Episode from YouTube To Anchor.Fm
uses: Schroedinger-Hat/youtube-to-anchorfm@v2.5.0
- name: Upload Episode from YouTube To Spotify
uses: Schroedinger-Hat/youtube-to-spotify@v2.5.0
env:
ANCHOR_EMAIL: ${{ secrets.ANCHOR_EMAIL }}
ANCHOR_PASSWORD: ${{ secrets.ANCHOR_PASSWORD }}
SPOTIFY_EMAIL: ${{ secrets.SPOTIFY_EMAIL }}
SPOTIFY_PASSWORD: ${{ secrets.SPOTIFY_PASSWORD }}
SPOTIFY_EMAIL: ${{ secrets.SPOTIFY_EMAIL }}
SPOTIFY_PASSWORD: ${{ secrets.SPOTIFY_PASSWORD }}
EPISODE_PATH: /github/workspace
```

**NOTE**: you need to [set up the secrets](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) for _ANCHOR_EMAIL_ and _ANCHOR_PASSWORD_. This environment variables are mandatory as they specify the sign in account.
**NOTE**: you need to [set up the secrets](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) for _SPOTIFY_EMAIL_ and _SPOTIFY_PASSWORD_. This environment variables are mandatory as they specify the sign in account.

Instead the _SPOTIFY_EMAIL_ and _SPOTIFY_PASSWORD_ are not mandatory but can still be set, if needed, and will be used for the new login form if the env variable _ANCHOR_LOGIN_ is set to false.
Instead the _SPOTIFY_EMAIL_ and _SPOTIFY_PASSWORD_ are not mandatory but can still be set, if needed, and will be used for the new login form if the env variable _SPOTIFY_LOGIN_ is set to false.


## Environment variables

### Login Type

Setting the `ANCHOR_LOGIN` to true makes the script login with the old anchor login type. Instead setting it to false makes the script login with the spotify account. By default the value is true.
Setting the `SPOTIFY_LOGIN` to true makes the script login with the old spotify login type. Instead setting it to false makes the script login with the spotify account. By default the value is true.

```yaml
env:
ANCHOR_LOGIN: true
SPOTIFY_LOGIN: true
```

### Draft Mode
Expand Down Expand Up @@ -164,8 +164,8 @@ env:

### 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.
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 spotify doesn't store publish date for draft episodes.
If `SET_PUBLISH_DATE` is not set, then spotify will choose the current date for publishing.

```yaml
env:
Expand Down Expand Up @@ -211,11 +211,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Upload Episode from YouTube To Anchor.Fm
uses: schroedinger-Hat/youtube-to-anchorfm@v2.5.0
- name: Upload Episode from YouTube To Spotify
uses: Schrodinger-Hat/youtube-to-spotify@v2.5.0
env:
ANCHOR_EMAIL: ${{ secrets.ANCHOR_EMAIL_GREATNEWS}} # OR secrets.ANCHOR_EMAIL_SADNEWS
ANCHOR_PASSWORD: ${{ secrets.ANCHOR_PASSWORD_GREATNEWS }} # OR secrets.ANCHOR_PASSWORD_SADNEWS
SPOTIFY_EMAIL: ${{ secrets.SPOTIFY_EMAIL_GREATNEWS }} # OR secrets.SPOTIFY_EMAIL_SADNEWS
SPOTIFY_PASSWORD: ${{ secrets.SPOTIFY_PASSWORD_GREATNEWS }} # OR secrets.SPOTIFY_PASSWORD_SADNEWS
EPISODE_PATH: /github/workspace/
Expand All @@ -237,14 +235,14 @@ the environment variables that you normally specify in the GitHub action YAML fi

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`.
Make sure to specify the mandatory environment variables for logging in to spotify,
`SPOTIFY_EMAIL` and `SPOTIFY_PASSWORD`.

If needed we can set the `SPOTIFY_EMAIL` and `SPOTIFY_PASSWORD` too, so they will be used to login with the new login type after changing `ANCHOR_LOGIN` to false.
If needed we can set the `SPOTIFY_EMAIL` and `SPOTIFY_PASSWORD` too, so they will be used to login with the new login type after changing `SPOTIFY_LOGIN` to false.

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

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

⚠ WARNING: This Potentially violates GitHub's Terms of service ⚠

Expand All @@ -270,41 +268,6 @@ curl https://scc-youtube.vercel.app/playlist-items/PLoXdlLuaGN8ShASxcE2A4YuSto3A

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

# Contributors

Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center"><a href="https://www.linkedin.com/in/%F0%9F%90%A7gabriele-puliti-b62915a9/"><img src="https://avatars.githubusercontent.com/u/12409541?v=4?s=100" width="100px;" alt="GabrielePuliti"/><br /><sub><b>GabrielePuliti</b></sub></a><br /><a href="#design-Wabri" title="Design">🎨</a> <a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/commits?author=Wabri" title="Code">💻</a> <a href="#maintenance-Wabri" title="Maintenance">🚧</a> <a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/pulls?q=is%3Apr+reviewed-by%3AWabri" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://www.mikilombardi.com"><img src="https://avatars.githubusercontent.com/u/6616203?v=4?s=100" width="100px;" alt="Miki Lombardi"/><br /><sub><b>Miki Lombardi</b></sub></a><br /><a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/commits?author=TheJoin95" title="Code">💻</a> <a href="#maintenance-TheJoin95" title="Maintenance">🚧</a> <a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/pulls?q=is%3Apr+reviewed-by%3ATheJoin95" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="habet.dev"><img src="https://avatars.githubusercontent.com/u/82916197?v=4?s=100" width="100px;" alt="Abe Hanoka"/><br /><sub><b>Abe Hanoka</b></sub></a><br /><a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/commits?author=abe-101" title="Code">💻</a> <a href="#maintenance-abe-101" title="Maintenance">🚧</a> <a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/pulls?q=is%3Apr+reviewed-by%3Aabe-101" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/matevskial"><img src="https://avatars.githubusercontent.com/u/44746117?v=4?s=100" width="100px;" alt="matevskial"/><br /><sub><b>matevskial</b></sub></a><br /><a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/commits?author=matevskial" title="Code">💻</a> <a href="#maintenance-matevskial" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/Amod02-prog"><img src="https://avatars.githubusercontent.com/u/83520862?v=4?s=100" width="100px;" alt="Amod Deshpande"/><br /><sub><b>Amod Deshpande</b></sub></a><br /><a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/commits?author=Amod02-prog" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/zephyrus3"><img src="https://avatars.githubusercontent.com/u/47828820?v=4?s=100" width="100px;" alt="Guilherme Costa"/><br /><sub><b>Guilherme Costa</b></sub></a><br /><a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/commits?author=zephyrus3" title="Code">💻</a> <a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/issues?q=author%3Azephyrus3" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/weltonrodrigo"><img src="https://avatars.githubusercontent.com/u/1644644?v=4?s=100" width="100px;" alt="Welton Rodrigo Torres Nascimento"/><br /><sub><b>Welton Rodrigo Torres Nascimento</b></sub></a><br /><a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/commits?author=weltonrodrigo" title="Documentation">📖</a> <a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/commits?author=weltonrodrigo" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/nicpuppa"><img src="https://avatars.githubusercontent.com/u/72783243?v=4?s=100" width="100px;" alt="Nicola Puppa"/><br /><sub><b>Nicola Puppa</b></sub></a><br /><a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/commits?author=nicpuppa" title="Documentation">📖</a></td>
<td align="center"><a href="http://matej.voboril.dev"><img src="https://avatars.githubusercontent.com/u/7128721?v=4?s=100" width="100px;" alt="Matt"/><br /><sub><b>Matt</b></sub></a><br /><a href="https://github.com/schroedinger-Hat/youtube-to-anchorfm/issues?q=author%3ATobiTenno" title="Bug reports">🐛</a></td>
</tr>
</tbody>
<tfoot>

</tfoot>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://allcontributors.org) specification.

# License

MIT
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Upload Episode from YouTube To Anchor.Fm'
description: 'An automation tool to publish your podcast from youtube to anchor.fm'
name: 'Upload Episode from YouTube To Spotify'
description: 'An automation tool to publish your podcast from youtube to spotify'
branding:
icon: 'upload-cloud'
color: 'green'
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "youtube-to-anchorfm",
"name": "youtube-to-spotify",
"version": "2.5.0",
"description": "Github action and general-purpose tool to publish youtube video as anchorfm episode",
"description": "Github action and general-purpose tool to publish youtube video as spotify episode",
"main": "src/index.js",
"scripts": {
"start": "node src/index.js",
Expand All @@ -20,7 +20,7 @@
"author": "thejoin",
"license": "MIT",
"keywords": [
"anchorfm",
"spotify",
"youtube"
],
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions src/environment-variables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const dotenv = require('dotenv');
const defaultValues = {
EPISODE_PATH: '.',
EPISODE_FILE: 'episode.json',
ANCHOR_LOGIN: true,
ANCHOR_EMAIL: '',
ANCHOR_PASSWORD: '',
SPOTIFY_LOGIN: true,
Wabri marked this conversation as resolved.
Show resolved Hide resolved
SPOTIFY_EMAIL: '',
SPOTIFY_PASSWORD: '',
SPOTIFY_EMAIL: '',
SPOTIFY_PASSWORD: '',
UPLOAD_TIMEOUT: 60 * 5 * 1000,
Expand Down Expand Up @@ -67,9 +67,9 @@ function getCompleteEpisodePath() {
module.exports = {
EPISODE_ID: getEnvironmentVariable('EPISODE_ID'),
EPISODE_PATH: getCompleteEpisodePath(),
ANCHOR_LOGIN: getBoolean(getEnvironmentVariable('ANCHOR_LOGIN')),
ANCHOR_EMAIL: getEnvironmentVariable('ANCHOR_EMAIL'),
ANCHOR_PASSWORD: getEnvironmentVariable('ANCHOR_PASSWORD'),
SPOTIFY_LOGIN: getBoolean(getEnvironmentVariable('SPOTIFY_LOGIN')),
SPOTIFY_EMAIL: getEnvironmentVariable('SPOTIFY_EMAIL'),
SPOTIFY_PASSWORD: getEnvironmentVariable('SPOTIFY_PASSWORD'),
SPOTIFY_EMAIL: getEnvironmentVariable('SPOTIFY_EMAIL'),
SPOTIFY_PASSWORD: getEnvironmentVariable('SPOTIFY_PASSWORD'),
UPLOAD_TIMEOUT: getEnvironmentVariable('UPLOAD_TIMEOUT'),
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { exit } = require('process');
const { configureLogger, getLogger, shutdownLogger } = require('./logger');
const env = require('./environment-variables');
const { getVideoInfo, downloadThumbnail, downloadAudio } = require('./youtube-yt-dlp');
const { postEpisode } = require('./anchorfm-pupeteer');
const { postEpisode } = require('./spotify-pupeteer');

const logger = getLogger();

Expand Down Expand Up @@ -41,7 +41,7 @@ async function main() {

await Promise.all([downloadThumbnail(youtubeVideoId), downloadAudio(youtubeVideoId)]);

logger.info('Posting episode to anchorfm');
logger.info('Posting episode to spotify');
await postEpisode(youtubeVideoInfo);
}

Expand Down
16 changes: 8 additions & 8 deletions src/anchorfm-pupeteer/index.js → src/spotify-pupeteer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function postEpisode(youtubeVideoInfo) {
/*
This is a workaround solution of the problem where the podcast
is sometimes saved as draft with title "Untitled" and no other metadata.
We navigate to the spotify/anchorfm dashboard immediately after podcast is
We navigate to the spotify/spotify dashboard immediately after podcast is
published/scheduled.
*/
await goToDashboard();
Expand All @@ -99,7 +99,7 @@ async function postEpisode(youtubeVideoInfo) {
});
logger.info(`data:image/png;base64,${Buffer.from(screenshotBinary).toString('base64')}`);
}
throw new Error(`Unable to post episode to anchorfm: ${err}`);
throw new Error(`Unable to post episode to spotify: ${err}`);
} finally {
if (browser !== undefined) {
await browser.close();
Expand Down Expand Up @@ -130,8 +130,8 @@ async function postEpisode(youtubeVideoInfo) {
}

async function loginAndWaitForNewEpisodeWizard() {
if (env.ANCHOR_LOGIN) {
await anchorLogin();
if (env.SPOTIFY_LOGIN) {
await spotifyLogin();
} else {
Wabri marked this conversation as resolved.
Show resolved Hide resolved
await spotifyLogin();
}
Expand All @@ -152,19 +152,19 @@ async function postEpisode(youtubeVideoInfo) {
});
}

async function anchorLogin() {
async function spotifyLogin() {
logger.info('-- Accessing Spotify for Podcasters login page');
await clickSelector(page, '::-p-xpath(//button[contains(text(), "Continue")])');

logger.info('-- Logging in');
/* The reason for the wait is because
anchorfm can take a little longer to load the form for logging in
spotify can take a little longer to load the form for logging in
and because pupeteer treats the page as loaded(or navigated to)
even when the form is not showed
*/
await page.waitForSelector('#email');
await page.type('#email', env.ANCHOR_EMAIL);
await page.type('#password', env.ANCHOR_PASSWORD);
await page.type('#email', env.SPOTIFY_EMAIL);
Wabri marked this conversation as resolved.
Show resolved Hide resolved
await page.type('#password', env.SPOTIFY_PASSWORD);
await clickSelector(page, 'button[type=submit]');
}

Expand Down