a bytes-like object is required, not 'str'
Closed this issue · 6 comments
I am experimenting with Poca and https://stitcher-rss.128.io/, which creates an RSS feed from a Stitcher Premium subscription.
The XML from the feed seems to be valid, but I'm getting the following error when I try to run poca:
- SUB ERROR (WTF with Marc Maron - Premium): a bytes-like object is required, not 'str'
any thoughts on what this could be?
Hi,
I'm the maintainer of the unofficial Stitcher feeds service. For context, the service generates a unique URL using basic auth to distinguish between each subscriber. An example URL would look like https://12345:12345@stitcher-rss.128.io/shows/96901/feed
.
Looking at access logs from the service while running poca-subscribe with a feed URL, I can see no request is made when basic auth credentials are provided. When the credentials are removed, a request is made (but the service returns a 401 forbidden since credentials are required).
I'm not too versed in Python development, but looking through the code it looks like this might be an issue with the underlying Feedparser library. If I had to guess, it's interpreting the string as feed data instead of an actual URL.
Thanks for your reply @adduc ! When I use the unofficial Stitcher feeds I am indeed getting a URL like https://12345:12345@stitcher-rss.128.io/shows/96901/feed with my own user number and password number.
When I look through the resulting xml file by eye it looks good, and when use that URL with PocketCasts it is seeing all the episodes OK. When I use that same address for poca I get the error I indicated. So you might be onto something with the Feedparser library misinterpreting the URL.
Finally got to the bottom of this. It is indeed an issue in feedparser. It only shows up when username:password is part of the url because only that bit gets base64 encoded which explains why I had never seen it. The base64 encoding function expects bytes not a string and feedparser just hands it a string.
There is a pull request with a fix waiting to happen. Until that gets fixed nothing poca can do, I'm afraid.
Fixed in feedparser 6.0.5 👍
You're very welcome, especially as I didn't do anything :) If you experience problems with it still after updating feedparser, please let me know.