DevilXD / TwitchDropsMiner

An app that allows you to AFK mine timed Twitch drops, with automatic drop claiming and channel switching.
MIT License
1.67k stars 162 forks source link

send_watch InvalidUrlClientError [{"error":"Can not find channel"}] #586

Open DevilXD opened 1 week ago

DevilXD commented 1 week ago
          Not sure if this was related but using the latest master I was able to mine for about 40 minutes and then received this:
16:04:03: Watching: InfernoTheFireLord
16:43:12: Watching: mellowteddy
16:43:33: ERROR: Exception in _watch_loop task
16:43:33: Traceback (most recent call last):
16:43:33:   File "channel.py", line 380, in send_watch
16:43:33:   File "contextlib.py", line 199, in __aenter__
16:43:33:   File "twitch.py", line 1313, in request
16:43:33:   File "gui.py", line 2198, in coro_unless_closed
16:43:33:   File "aiohttp\client.py", line 1343, in send
16:43:33:   File "aiohttp\client.py", line 592, in _request
16:43:33: aiohttp.client_exceptions.InvalidUrlClientError: %5B%7B%22error%22:%22Can%20not%20find%20channel%22%7D%5D
16:43:33: 
16:43:33: The above exception was the direct cause of the following exception:
16:43:33: 
16:43:33: Traceback (most recent call last):
16:43:33:   File "utils.py", line 132, in wrapper
16:43:33:   File "twitch.py", line 888, in _watch_loop
16:43:33:   File "channel.py", line 401, in send_watch
16:43:33: exceptions.MinerException
16:43:33: Exiting...
16:43:33: 
16:43:33: Application Terminated.
16:43:33: Close the window to exit the application.

Originally posted by @introvertism in https://github.com/DevilXD/TwitchDropsMiner/issues/583#issuecomment-2433524706

DevilXD commented 4 days ago

Related: https://github.com/DevilXD/TwitchDropsMiner/issues/590#issuecomment-2439837554

jordyamc commented 4 days ago

I had a similar error but with InvalidURL

03:41:41: ERROR: Exception in _watch_loop task
03:41:41: Traceback (most recent call last):
03:41:41:   File "channel.py", line 381, in send_watch
03:41:41:   File "contextlib.py", line 199, in __aenter__
03:41:41:   File "twitch.py", line 1313, in request
03:41:41:   File "gui.py", line 2208, in coro_unless_closed
03:41:41:   File "aiohttp\client.py", line 1178, in send
03:41:41:   File "aiohttp\client.py", line 545, in _request
03:41:41:   File "aiohttp\client_reqrep.py", line 326, in __init__
03:41:41:   File "aiohttp\client_reqrep.py", line 400, in update_host
03:41:41: aiohttp.client_exceptions.InvalidURL: %5B%7B%22url%22:%22/api/channel/hls/multiversus.m3u8?sig=1585980187f867e3540788aee51c17be3c7ea060%5Cu0026token=%7B%22adblock%22:false,%22authorization%22:%7B%22forbidden%22:false,%22reason%22:%22%22%7D,%22blackout_enabled%22:false,%22channel%22:%22multiversus%22,%22channel_id%22:735931830,%22chansub%22:%7B%22restricted_bitrates%22:%5B%5D,%22view_until%22:1924905600%7D,%22ci_gb%22:true,%22geoblock_reason%22:%22content_geoblocked%22,%22device_id%22:%22EbiUgsm409aCa4hsGuPKWSCWRfU0UXDu%22,%22expires%22:1730023300,%22extended_history_allowed%22:false,%22game%22:%22%22,%22hide_ads%22:false,%22https_required%22:true,%22mature%22:false,%22partner%22:false,%22platform%22:%22web%22,%22player_type%22:%22site%22,%22private%22:%7B%22allowed_to_view%22:true%7D,%22privileged%22:false,%22role%22:%22%22,%22server_ads%22:true,%22show_ads%22:true,%22subscriber%22:false,%22turbo%22:false,%22user_id%22:59135981,%22user_ip%22:%22187.190.204.225%22,%22version%22:2%7D%22,%22error%22:%22Content+Restricted+In+Region%22,%22error_code%22:%22content_geoblocked%22,%22type%22:%22error%22%7D%5D
03:41:41: 
03:41:41: The above exception was the direct cause of the following exception:
03:41:41: 
03:41:41: Traceback (most recent call last):
03:41:41:   File "utils.py", line 132, in wrapper
03:41:41:   File "twitch.py", line 888, in _watch_loop
03:41:41:   File "channel.py", line 402, in send_watch
03:41:41: exceptions.MinerException
DevilXD commented 4 days ago

That's another "error":"Content+Restricted+In+Region", just like in the linked comment. I'm working on this.

imranh2 commented 3 days ago

@DevilXD I implmented a workaround for the geoblock here https://github.com/DevilXD/TwitchDropsMiner/pull/593

DevilXD commented 3 days ago

I already have a working "workaround", that emits an error when a case like this is detected. The thing is, apparently I forgot to push it yesterday, when I was testing how it works. Will do so in about an hour or two.

The issue is, that won't solve much. There's currently no way to mark a channel as "unwatchable", as long as it's online and streaming an applicable game. Setting it offline won't work, because the redundant viewers count update logic in the miner will set it back online a few minutes later. I'll need to think about implementing a way to do that later on, but for now, the change I'll soon push will simply make the miner at least not crash in cases like this.

DevilXD commented 3 days ago

https://github.com/DevilXD/TwitchDropsMiner/commit/3b4923a289fe689798faff094676e6968d9e11e6 has been put in place to turn this issue into a non-fatal error, but an error nonetheless. The next logical step would be to implement a way for the miner to detect and mark a stream as "unwatchable", or "not possible to watch", due to various reasons (like the geo-blocking / "content restricted in region" in this case).

It sounds as something relatively simple to do, but at the same time, not really. This is because properly detecting a geo-blocked stream would require me having access to one, which I currently do not have, nor can find. Twitch search specifically won't show me geo-blocked streams: https://help.twitch.tv/s/article/how-does-search-work?language=en_US#whyresults

My only bet would be for someone else to supply me with a link or channel name to a geo-blocked stream. For now though, I've managed to find this website, that lists banned streamer accounts/channels: https://streamerbans.com/streamers?page=1&banStatus=banned I'll try using that to do the testing instead.

jordyamc commented 2 days ago

I read that some Korean streams using content from Korean bands are sometimes geo-blocked to korea

In my case the miner was trying to watch this channel multiversus that is geo-blocked to USA only

But I don't know if it was only blocked during that stream for the drops or all of the streams are blocked

DevilXD commented 1 day ago

I see, thank you. I'll keep an eye on the channel to see if I can catch it streaming the geo-blocked stream.