Heckie75 / kodi-addon-podcast

Subscribe to podcasts in KODI
MIT License
14 stars 3 forks source link

Some Servers Give 403 Response If No User-Agent in Request Header #4

Closed stobb3s closed 3 years ago

stobb3s commented 3 years ago

I updated to the latest version 2.0.1 from the official Matrix repo. Thank you for publishing your add-on, the community greatly appreciates your work. It seems that the change to the requests module has caused a couple of my podcast feeds to fail to load. The server is returning a 403 Forbidden response. After some brief research, I found that some servers will reject any request that does not have a User-Agent in the header. I changed the code to below and it fixed the issue:

useragent = f"{settings.getAddonInfo('id')}/{settings.getAddonInfo('version')} (Kodi/{xbmc.getInfoLabel('System.BuildVersionShort')})"
headers = {'User-Agent': useragent}
res = requests.get(url,headers=headers)

For my installation, this causes the User-Agent to be plugin.audio.podcasts/2.0.1 (Kodi/19.1). But you can use any arbitrary string for the User-Agent, I test several random strings and it accepted all of them.

To reproduce the issue, you may use this URL https://www.codingblocks.net/podcast-feed.xml

Heckie75 commented 3 years ago

I changed it locally. I am going to push it after a few testing.

Heckie75 commented 3 years ago

May be you like to test the latest version that I have pushed to my repository. There is also the new setting ;-) Afterwards I would create the PR in the official repo.

stobb3s commented 3 years ago

Works great.