fix(youtube): a related page is empty only on YouTube's own word
The watch frame alone read as "nothing related" — so a related column YouTube moved, or a list drawn by renderers this does not read, answered an empty list instead of an error. Now only the "isn't available" promo YouTube draws for a video it no longer has is an empty page; anything else it cannot read is a ScrapeError. The flattening of a video renderer and the read of the continuation token are one each, in innertube, for the search and the related scrape.
This commit is contained in:
@@ -191,6 +191,26 @@ def test_a_video_youtube_no_longer_has_is_an_empty_page(net):
|
||||
assert related_scrape.related("aaaaaaaaaaa") == {"items": [], "next_page_token": None}
|
||||
|
||||
|
||||
def test_a_watch_frame_with_no_related_column_and_no_word_why_is_an_error(net):
|
||||
# The frame alone, its related column moved somewhere this does not look: a lost shape, not
|
||||
# "nothing related".
|
||||
page = copy.deepcopy(FIRST)
|
||||
watch = page["contents"]["twoColumnWatchNextResults"]
|
||||
watch["sideColumn"] = watch.pop("secondaryResults")
|
||||
_answer(net, page)
|
||||
with pytest.raises(related_scrape.ScrapeError):
|
||||
related_scrape.related("SdTZAMDKrNY")
|
||||
|
||||
|
||||
def test_a_related_list_drawn_by_renderers_this_does_not_read_is_an_error(net):
|
||||
page = copy.deepcopy(FIRST)
|
||||
results = _results(page)
|
||||
results[:] = [{"videoTileViewModel": entry} for entry in results]
|
||||
_answer(net, page)
|
||||
with pytest.raises(related_scrape.ScrapeError):
|
||||
related_scrape.related("SdTZAMDKrNY")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"answer",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user