Properly handle non-existing channels

Currently, this deleted channel returns a stackstrace on NewLeaf https://www.youtube.com/channel/UC6v6ljwkDGjk8Q7Dj-yjuqg

Traceback (most recent call last):
  File "/home/cloudtube/newleaf-venv/lib/python3.5/site-packages/cherrypy/_cprequest.py", line 638, in respond
  File "/home/cloudtube/newleaf-venv/lib/python3.5/site-packages/cherrypy/_cprequest.py", line 697, in _do_respond
    response.body = self.handler()
  File "/home/cloudtube/newleaf-venv/lib/python3.5/site-packages/cherrypy/lib/encoding.py", line 219, in __call__
    self.body = self.oldhandler(*args, **kwargs)
  File "/home/cloudtube/newleaf-venv/lib/python3.5/site-packages/cherrypy/lib/jsontools.py", line 59, in json_handler
    value = cherrypy.serving.request._json_inner_handler(*args, **kwargs)
  File "/home/cloudtube/newleaf-venv/lib/python3.5/site-packages/cherrypy/_cpdispatch.py", line 54, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "/home/cloudtube/NewLeaf/index.py", line 83, in channels
    return extract_channel(ucid)
  File "/home/cloudtube/NewLeaf/extractors/channel.py", line 26, in extract_channel
    channel_metadata = yt_initial_data["metadata"]["channelMetadataRenderer"]
KeyError: 'metadata'

This should be properly handled, and the same way as Invidious API.

The error code also needs to be handled in CloudTube.

Assigned to
2 years ago
3 months ago

~cadence 2 years ago

This should be properly handled, and the same way as Invidious API.

Invidious says: Missing hash key: "interactiveTabbedHeaderRenderer" (KeyError) from /usr/share/crystal/src/hash.cr:1027:11 in '[]' from /usr/share/crystal/src/json/any.cr:102:7 in '[]' from src/invidious/channels.cr:831:14 in 'get_about_info' from src/invidious.cr:2283:15 in '->' from /usr/share/crystal/src/primitives.cr:255:3 in '->' from /usr/share/crystal/src/primitives.cr:255:3 in 'process_request'

So I think I'll just return, "This channel does not exist".

~cadence 2 years ago

Implemented in NewLeaf in commit 57b0a88a2e4af22ed6003a9b79f4ca7711317a9e.

CloudTube will wait. I need a better abstraction system for the calls to the instance before I implement this, or else the codebase will become more messy than I deem acceptable.

~lomanic 3 months ago

This issue can be closed, there's no stacktrace returned anymore by CloudTube for non-existing channels.

Register here or Log in to comment, or comment via email.