0

I'm setting up a streaming server running Ubuntu 16.04 for personal use, using TVHeadend as a PVR backend for Kodi. TVheadend needs a so-called "XMLTV" file to provide EPG functionality, and this file needs to be updated (downloaded from the TV provider) twice a day.

My TV provider sent me a URL like this to download the file:
http://srv:port/xmltv.php?username=xxxx&password=yyyyyyy

The problem is, even sending user and password in the URL, wget still gets the 401 (Unauthorized) error from the server.

I've already tried sending user and password as arguments on the wget command line (wget --user username --password PASS), but to no avail.

I need to fix this so I can create a Cron Job to automatically update the EPG every 12 hours.

dessert
  • 39,982
  • 1
    Does it work if you go to the site with a browser? – Organic Marble Apr 26 '18 at 04:12
  • Did you quote username and password properly? I'd use single quotes: wget --user 'USERNAME' --password 'PASSWORD' http://SERVER:PORT/xmltv.php – dessert Apr 26 '18 at 06:45
  • 1
    @OrganicMarble yes, opening the URL in a browser gives me the expected result, a beautiful ready-to-use XMLTV.XML file. – Alex Silva Apr 26 '18 at 11:21
  • @dessert I did this, but it did not work, Wget says "unknown authentication scheme". – Alex Silva Apr 26 '18 at 11:30
  • Does it work with curl? curl -u 'username:password' http://SERVER:PORT/xmltv.phpor maybe with an added --anyauth. – dessert Apr 26 '18 at 11:42
  • @dessert no... Just an empty file – Alex Silva Apr 26 '18 at 11:50
  • Are you sure the server does not do some User-Agent sniffing. to change its reply based on client? It is bad but it happens often. Try wget with an user-agent string being the same one as your browser. – Patrick Mevzek Apr 27 '18 at 02:32
  • @PatrickMevzek No, I've already tried sending user agent with curl using the -a flag, nothing, still 401 error. I'm going crazy because I'm not able to make it work in any way. The tech guys from my TV provider also tried to help me but they could not get this to work. It looks like I'm going to have to transfer the file manually via SFTP every 12 hours! So sad! – Alex Silva Apr 27 '18 at 04:41
  • Sniff the exchange when it is happening successfully with the browser to see really what is exchanged. – Patrick Mevzek Apr 27 '18 at 04:48
  • 1
    @PatrickMevzek I managed to solve this challenge, just removed the String username and password from the URL and put as arguments to wget, like this: "wget --post-data 'username=XXXX&password=yyyyyyyy' http://srv:port/xmltv.php". I was using the basic HTTP authentication instead of the post method and this was the source of the problem, now everything works like a charm! – Alex Silva Apr 27 '18 at 12:19

0 Answers0