FriendTeamInc / VodBot

A command line interface VOD and Clip manager for Twitch.
MIT License
14 stars 1 forks source link

Unexpected exception when processing a channel that does not exist #68

Closed NotQuiteApex closed 1 year ago

NotQuiteApex commented 1 year ago

If VodBot attempts to query about a channel that does not exist, the program crashes due to some hasty subscripting (bad assumptions about the return type being a dictionary and not-null/not-None).

Quick fix would be adding checks at each stage of the subscript, though "data" field can probably be assumed to be not-null due to this always being filled on a successful query.

apex@serv ~ $ vodbot pull
Loading config... Loading channel data... Checking directories... Pulling video lists...
notquiteapex: 1 VODs & 1 Clips
percy_creates: 0 VODs & 0 Clips
juicibit: 0 VODs & 0 Clips
alkana: Traceback (most recent call last):
  File "/home/apex/.local/bin/vodbot", line 8, in <module>
    sys.exit(deffered_main())
  File "/home/apex/.local/lib/python3.10/site-packages/vodbot/__main__.py", line 82, in deffered_main
    main()
  File "/home/apex/.local/lib/python3.10/site-packages/vodbot/__main__.py", line 180, in main
    import_module(".commands.pull", "vodbot").run(args)
  File "/home/apex/.local/lib/python3.10/site-packages/vodbot/commands/pull.py", line 75, in run
    channelvods = [vod for vod in twitch.get_channel_vods(channel) if vod.id not in cache.channels[channel.login].vods]
  File "/home/apex/.local/lib/python3.10/site-packages/vodbot/twitch.py", line 208, in get_channel_vods
    resp = gql.gql_query(query=query).json()["data"]["user"]["videos"]
TypeError: 'NoneType' object is not subscriptable

Found this because Iris now goes by "iris_prismatica" on Twitch, rather than "alkana".