Kodi Community Forum
Is it possible to change default header (User-Agent) without recompiling Kodi? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: OS independent / Other (https://forum.kodi.tv/forumdisplay.php?fid=228)
+---- Thread: Is it possible to change default header (User-Agent) without recompiling Kodi? (/showthread.php?tid=365126)



Is it possible to change default header (User-Agent) without recompiling Kodi? - pintassilgo - 2021-10-25

I have a URL of a remote playlist that I want to use in Kodi. This playlist updates almost everyday and I don't have control over it. Video URLs in this playlists requires common browser User-Agent i.e. Kodi's default like "Kodi/19.0-ALPHA1 (X11; Linux x86_64) ..." results in 403 Forbidden error.

If I had control over the playlist, I could append |User-Agent=... to every media item, but I don't. And I can't simply fork the playlist because of the frequent updates, URLs would expire quickly.

I guess the only easy way to solve this would be by changing Kodi's default User-Agent. Is it possible?


RE: Is it possible to change default header (User-Agent) without recompiling Kodi? - jjd-uk - 2021-10-25

Do you use these playlists in IPTV Simple? as that has a user agent setting in the advanced tab of the addon settings. Not something I've ever used so if you've any questions on usage ask in https://forum.kodi.tv/forumdisplay.php?fid=215


RE: Is it possible to change default header (User-Agent) without recompiling Kodi? - pintassilgo - 2021-10-25

I'm using Playlist Loader because I need to use multiple playlists and IPTV Simple supports only one.

IPTV Simple uses C++ to set User-Agent, I don't want to compile anything (actually I don't know how to do it).

But I found a way. Forked Playlist Loader adding the following code:
python:

if not url.startswith('plugin') and not re.search('(&|\|)user-agent=', url, re.IGNORECASE):
    if re.search('\|', url):
        url += '&User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0'
    else:
        url += '|User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/94.0'