Skip to content

Commit

Permalink
Merge pull request #47 from matevskial/feature/merge-youtube-to-ancho…
Browse files Browse the repository at this point in the history
…rfm-2

Merge the refactor made in repository youtube-to-anchorfm-2
  • Loading branch information
abe-101 authored Sep 8, 2022
2 parents a32e872 + 9819cb5 commit e9cc52e
Show file tree
Hide file tree
Showing 13 changed files with 761 additions and 2,165 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ANCHOR_EMAIL=user@domain
ANCHOR_PASSWORD=password
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
*.mp4
*.m4a
*.webm
dist/episode*
dist/episode*
.env
11 changes: 5 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
FROM ubuntu:18.04
FROM ubuntu:20.04

RUN apt-get update && apt-get install -y sudo
RUN apt-get -y upgrade
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
RUN curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
RUN apt-get install -y python
RUN apt-get install -y nodejs
RUN apt-get install --reinstall libgtk2.0-0 -y
RUN apt-get install -y libgbm-dev
RUN apt-get install libnss3 libnss3-tools libxss1 libgtk-3-0 -y
RUN apt-get install chromium-browser -y
# To allow MP3 conversion
RUN apt-get install ffmpeg -y

COPY index.js /index.js
COPY episode.json /episode.json
# used by nmp ci
COPY src /src
COPY package-lock.json /package-lock.json
COPY package.json /package.json
COPY entrypoint.sh /entrypoint.sh
COPY episode.json /episode.json

RUN chmod 777 /entrypoint.sh
ENV LC_ALL=en_US.UTF-8
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
56 changes: 41 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ Every contribution it is appreciated, also a simple feedback.

## How it works

The workflow is using `youtube-dl` library and `puppeteer`.

The first one is a npm module used for downloading the video / audio from YouTube, meanwhile Puppeteer will upload the generated file into the Anchor.fm dashboard (by logging it).

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 use a docker image built over ubuntu 18.04. It take some times to setup the environment (installing dependencies and chromium browser).
The action uses a docker image built over Ubuntu. It takes some time to setup the environment before runnign the script.

## How can I use it?
**NOTE**: in order for the script to run its necessary for there to be at least one episode already published on anchorFM manually, because on a brand new anchor fm account the steps to publish are bit different, it asks questions about the channel.

## How can I use 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).

Expand Down Expand Up @@ -57,11 +55,28 @@ jobs:
**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.
In order for the tool to run its necessary for there to be at least one episode already published on anchorFM (it can be deleted after a successful run)
## How can I setup for development and use the script locally?
To run the script locally, you need ```python3``` and ```ffmpeg``` to be avaliable 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 normaly specify in the Github action YAML file.

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

## Process a YouTube playlist
Make sure to specify the mandatory environment variables for logging in to Anchorfm,
```ANCHOR_EMAIL``` and ```ANCHOR_PASSWORD```.

Right now, you can process a full playlist (one way only) with
Finally, you can do ```npm start``` to execute the script.

## How to upload a YouTube playlist to Anchorfm using this script?

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

```
curl https://scc-youtube.vercel.app/playlist-items/PLoXdlLuaGN8ShASxcE2A4YuSto3AblDmX \
Expand All @@ -80,7 +95,9 @@ curl https://scc-youtube.vercel.app/playlist-items/PLoXdlLuaGN8ShASxcE2A4YuSto3A
This must be run on the folder where your episode.json is.
## Draft Mode
## 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.
Expand All @@ -90,7 +107,7 @@ env:
SAVE_AS_DRAFT: true
```

## Audio conversion options
### 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.
Expand All @@ -104,23 +121,23 @@ env:
POSTPROCESSOR_ARGS: "ffmpeg:-ac 1"
```
## Explicit Mode
### Explicit Mode
By setting the `IS_EXPLICIT`, the new episode will be marked as explicit.
```yaml
env:
IS_EXPLICIT: true
```

## Thumbnail Mode
### Thumbnail Mode

By setting the `LOAD_THUMBNAIL`, the new episode will include the video thumbnail as the episode art.
```yaml
env:
LOAD_THUMBNAIL: true
```

## Add YouTube URL to Podcast Description
### 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.
Expand All @@ -130,11 +147,20 @@ 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 Anchofm doesn't store publish date for draft episodes.
If `SET_PUBLISH_DATE` is not set, then Anchorfm will choose the current date for publishing.
```yaml
env:
SET_PUBLISH_DATE: true
```

# Credits

[@thejoin](https://github.com/thejoin95) & [@wabri](https://github.com/wabri)
[@thejoin](https://github.com/thejoin95)

[@wabri](https://github.com/wabri)

# License

Expand Down
3 changes: 1 addition & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
# Guarantee that we are on the same path as our *.js scripts
cd /
npm ci # more suitable for installs from scratch
sudo npm i puppeteer --unsafe-perm=true --allow-root
node index.js
npm start
178 changes: 0 additions & 178 deletions index.js

This file was deleted.

Loading

0 comments on commit e9cc52e

Please sign in to comment.