Yetangitu / Spodcast

Spodcast is a caching Spotify podcast to RSS proxy. Using Spodcast you can follow Spotify-hosted netcasts/podcasts using any player which supports RSS, thus enabling the use of older hardware which is not compatible with the Spotify (web) app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

duration_ms is not defined

heywoodlh opened this issue · comments

Traceback (most recent call last):
  File "/usr/local/bin/spodcast", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/spodcast/__main__.py", line 39, in main
    args.func(args)
  File "/usr/local/lib/python3.7/site-packages/spodcast/app.py", line 24, in client
    download_episode(episode)
  File "/usr/local/lib/python3.7/site-packages/spodcast/podcast.py", line 143, in download_episode
    path, size = download_stream(stream, filepath)
  File "/usr/local/lib/python3.7/site-packages/spodcast/podcast.py", line 115, in download_stream
    delta_want = (downloaded / size) * (duration_ms/1000)
NameError: name 'duration_ms' is not defined

This error is not very verbose, how do I work past it?

Here's my command:

spodcast --root-path /tmp/spodcast/html --credentials-location /tmp/spodcast/creds.json --max-episodes 10 -p --chunk-size 1000 --log-level debug --rss urls 'https://open.spotify.com/show/4rOoJ6Egrf8K2IrywzwOMk'

Run this command in two steps:

  1. First step is root path preparation and login (needs to be done only once)
  2. Second step is show download

Also, you forgot to tell it where to put the configuration file: -c /tmp/spodcast/html/spotcast.json. Put it in the --root-path so the feed manager can get at it. The same goes for the credentials file. Hide those files in the web server config, that way the spodcast config is entirely self-contained and as such can be moved around without problems. If you do not plan to use the RSS feed service you can place those files wherever you want, just as long as you tell spodcast where to find the config file on each invocation.

Do you have a reason for using such a small chunk-size? The smaller the value, the more calls to Spotify are made. The default is 50000 and has worked fine for me.

You're using the -rss option without the required parameter ( yes, true or 1 when you want to use RSS, no, false or 0 if you don't), instead giving urls which is not a valid parameter (hence the error message "not a boolean"). Since RSS-mode is enabled by default you don't need to add it if you plan to use RSS.

You only need to run with -p once at the first invocation of spodcast or if/when you want to change from a non-RSS configuration to one supporting it.

Here's an optimised version of your command:

First step, with login through text file spotify.rc containing a username and password separated by a space character:

spodcast -c /tmp/spodcast/html/spodcast.json --root-path /tmp/spodcast/html --credentials-location /tmp/spodcast/html/creds.json  -p -l spotify.rc

This uses login through a text file, I'll add a separate "interactive login command" in a next version. If you want to use interactive login now you can do this by adding --max-episodes 0 followed by your Spotify show URL after this (first) command.
You only need to run this command once.

Second step:

spodcast -c /tmp/spodcast/html/spodcast.json --max-episodes 10 'https://open.spotify.com/show/4rOoJ6Egrf8K2IrywzwOMk'

Since the first step created a config file for spodcast you just need to tell it where it is using -c /path/to/config/file.json, rest of the parameters relate to the show/episode(s) you want to download. This second step command can be repeated at a later moment to get fresh episodes since it will skip existing files by default.

Awesome, thank you for the explanation!