Skip to content
Frank de Lange edited this page Feb 16, 2022 · 1 revision

Another day, another wiki, so here goes:

Spodcast makes it possible to listen to Spotify-hosted podcasts on devices which are not supported by the Spotcast (web) app. As long as your device supports RSS feeds it should be able to be made to work.

How to install Spodcast

Spodcast is hosted on PyPi and as such can be easily installed through pip:

$ pip install spodcast

This installs Spodcast for the user who invoked the command. If the spodcast CLI command is to be used by multiple users - e.g. www-data being the user under which web services tend to run on Debian-related distributions (and others) - it should be installed globally by running sudo pip install spodcast or invoking su -c 'pip install spodcast', depending on whether sudo is available (to you).

Configuration

As stated in the README there are two different use scenarios for Spodcast in that it can either be used as a web service or a command line app. The former makes it possible to add, configure and delete feeds from any (mobile) device while the latter is more fitting to the way of the (keyboard) warrior. These use modes are not exclusive, it is possible to add feeds to the web UI through the CLI as long as the permissions on the --root-path allow so.

RSS service

To use the RSS feed service you need a web server with PHP support. It does not need to be a high-performance server, a Raspberry Pi does just fine. Configure the web server to serve .index.php as the index page. This is more or less the default PHP configuration with the following remarks:

  1. The index is named .index.php (notice the leading dot, this is a hidden file) instead of index.php
  2. You should block access to files with json and info extensions. The former is an extra safeguard against leaking Spotify credentials, these are stored in the Spodcast root directory with a naming scheme of spodcast-cred-MD5_HAS_OF_SPOTIFY_USERNAME.json and as such are not easily guessable. The latter files are used to configure feeds, they are not security-critical but given that there is no need for web access they should be blocked anyway.

example config: nginx + php-fpm

server { listen 80; listen [::]:80; server_name spodcast.example.org;

    root /mnt/audio/spodcast;

    # serve the hidden .index.php file 
    index .index.php;

    # these files should not be accessible
    location ~\.(json|info)$ {
            deny all;
            return 404;
    }

    location / {
            try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    }

}

example config: apache + php (php-fpm or mod_php)

<VirtualHost *:80>
...
...
        ServerName spodcast.example.org
        DocumentRoot /mnt/audio/spotcast
        DirectoryIndex .index.php
        <FilesMatch ".+\.(json|info)$">
                Require all denied
        </FilesMatch>
...
...
</VirtualHost>

Configuring Spodcast

The first time Spodcast is run it will create a configuration file based on the parameters given on the command line. This file will be used for subsequent calls so make sure to use the correct parameters. If you mess up you can either edit the (json-formatted) file by hand or just delete it and run spodcast with the correct parameters. Since Spodcast can not do anything sensible without a Spotify username and password these need to be provided on the first run as well. If you're planning to use the RSS feed service make sure to run these commands as the web server user or change the ownership of the --root-path so that the web server user or group has read/write/execute permissions. If you want to combine the two you can run the commands under your own account and run chgrp -R www-data /mnt/audio/spodcast; chmod -R g+rwx /mnt/audio/spodcast so that the feed manager script can create and update feeds. If your installation runs php-fpm under a different account from that for the web server you'll need to use the account used for php-fpm here. The following parameters are mandatory on the first run:

The root path, where shows will be downloaded: --root-path

--root-path /mnt/audio/spodcast

The configuration file, best placed in the root path when using the RSS feed service or in ~/.config/spodcast when only using the CLI. Provide the full path: -c or --config-location

-c /mnt/audio/spodcast/spodcast.json or -c ~/config/spodcast/spodcast.json

If you want to use the RSS feed service the root path needs to be prepared, e.g. the feed manager script and related data need to be created there: -p or --prepare-feed

Spotify credentials can be provided interactively by responding to the 'Username:' and 'Password:' prompts given on first use or by creating a text file containing the Spotify username and password on a single line, separated by a space (' ') character, e.g.:

$ cat spotify.rc
spotifyusername1 z00perz33cr3tp4ssw0rd

This file is fed to spodcast through the login command: -l or --login

-l spotify.rc

All this combined makes for a working version of Spodcast:

$ spodcast -c /mnt/audio/spodcast/spodcast.json --root-path /mnt/audio/spodcast -p -l spotify.rc

If the web server is configured as it should you should now be able to navigate to the feed manager in a browser of choice to add feeds. Alternatively this can be done through the CLI as well, the end result is the same.

Feeds

Adding a feed in the web UI is rather self-explanatory: just drag, paste or type a Spotify show or episode link into the box on top of the feed manager, hit Enter or press Add and the feed will be added. This may take a while, depending on your connection speed. Adding the same feed through the CLI (assuming user/group permissions are configured correctly, see above) is just as simple, all that is needed is to feed the show or episode link to the spodcast command:

$ spodcast -c /mnt/audio/spodcast/spodcast.json --max-episodes 3 https://open.spotify.com/show/4rOoJ6Egrf8K2IrywzwOMk

This will add a feed for The Joe Rogan Experience, syncing the last three episodes (--max-episodes 3). If you're interested in a specific episode you'd feed that link to spodcast in the same way.

Feed readers

RSS feeds generated by Spodcast are served directly from the feed directory using the same protocol (http or https) as the feed manager. If the feed manager is reached through https://spodcast.example.org/ and the show you want to configure is called 100 ways to spend time while weightless you'd reach it through:

https://spodcast.example.org/100_ways_to_spend_time_while_weightless

Some shows contain URL-unfriendly characters in their names, these are filtered out by Spodcast. You can see the correct feed address in the info block in the feed manager, look for the RSS icon.