marhoy/nrk-download

Unable to download series: 412 Client Error

xim opened this issue · 9 comments

xim commented
$ nrkdownload -s fantorangen
ERROR: Not able to parse search-results: 412 Client Error: Precondition Failed for url: https://tvapi.nrk.no/v1/search/fantorangen
Traceback (most recent call last):
  File "/home/foo/.local/bin/nrkdownload", line 11, in <module>
    load_entry_point('nrkdownload==0.10.dev1+g4be2cc0', 'console_scripts', 'nrkdownload')()
  File "build/bdist.linux-x86_64/egg/nrkdownload/commandline_script.py", line 40, in main
  File "build/bdist.linux-x86_64/egg/nrkdownload/nrktv.py", line 356, in search_from_cmdline
TypeError: object of type 'NoneType' has no len()

Hm, interesting...
NRK seems to have changed the API, so one needs to send a specific header in order to get results back.
That means it's not possible to use this tool until we find out how to use the new API.

Are you willing to be a tester for the new version that works around the new API-restrictions?

I would. When trying just now from the v.2 branch in a brand new virtualenv, I get
sqlite3.OperationalError: unable to open database file.

Hehe, sorry about that...
I had turned on caching for the API requests, but I haven't yet found a good place to store the cache database (persistent between runs).

Can you pull branch v.2 from github try again?
I have disabled the cache for now (has to be enabled with the --cache option).

In one case it works for single episodes, but not for seasons or shows:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 13: ordinal not in range(128)

With otehrs I get a list of episodes but can`t choose.

Enter a number or Python-style interval (e.g. 8 or -2: or : ). (q to quit): 3
Sorry, not a valid input: expected string or buffer

Also, the Readme still says that you can search and mentions the old -u.

Are you running this with Python 2.7 under OS X?
So far, I've only been testing with Python 3.6.

For the builtin Python 2.7 under OS X, you need to set an environment variable:
https://github.com/marhoy/nrk-download#special-considerations-for-macos-os-x

The documentation is not updated yet, but nrkdownload -h is up to date wtr. options.

Python 2.7 under Linux with LC_CTYPE=de_DE.utf8 and this venv

Successfully installed certifi-2018.10.15 chardet-3.0.4 future-0.17.1 idna-2.7 nrkdownload python-dateutil-2.7.5 requests-2.20.1 requests-cache-0.4.13 six-1.11.0 tqdm-4.28.1 urllib3-1.24.1

I can confirm, that everything I tried works fine with 3.6 under Linux.

On the other hand, maybe just drop 2.7 anyway?

I found and fixed three Python 2 problems.
Should work also under Python 2 now.

...time to add some tests and start using tox... :)

I would like to from Python 2.7 compatibility, but I think some people still use it...

Fixed in version 2.0.0