Update npo_watchlist#1664
Conversation
* The NPO3 site has been updated to list fragments with the episode too, and list 'articles' also; new trick to only find episodes by looking at running time * Add running time as npo_runtime (should also help with the date parsing) * Update the test, added npo_runtime check; but also make sure to test for that things that should NOT be listed are asserted as None
| @@ -201,33 +201,36 @@ def _parse_episodes_npo3(self, task, config, series_name, page, series_info): | |||
|
|
|||
| entries = list() | |||
| for listItem in page.findAll('div', class_='item'): | |||
There was a problem hiding this comment.
I know this wasn't introduced in this PR but please change listItem to list_item
| e['npo_name'] = series_info['npo_name'] | ||
| e['npo_description'] = series_info['npo_description'] | ||
| e['npo_language'] = series_info['npo_language'] | ||
| if subtitle[1]: # if runtime is available in the subtext |
There was a problem hiding this comment.
Will the previous split always work? If not, this may raise an IndexError
There was a problem hiding this comment.
The previous split might indeed fail, because there is no easy way to check if 100% of the site confirms to this new subtext format. I will add an extra check
There was a problem hiding this comment.
Hmm, I checked the current way, it and this should actually work already correctly... and the split() always returns a list (of e.g. zero length if the splitted symbol is not there);
and the if-statement correctly handles the situation if the key exists in the list. It does not spawn any error with any input.
So I will leave this as it is, if you don't mind.
There was a problem hiding this comment.
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> l = 'nodots'.split('.')
>>> l
['nodots']
>>> l[1]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index out of range
>>>
There was a problem hiding this comment.
but it is not l[1]
it is if l[1]:
There was a problem hiding this comment.
That will still fail. No matter what precedes l[1] it is a direct access to the 2nd element in the list.
>>> if l[1]:
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index out of range
>>>
There was a problem hiding this comment.
It'll still throw that error. Do if len(l) > 1
There was a problem hiding this comment.
Ok, I will update it
Motivation for changes:
NPO.nl site has been changed again