gumerov-amir / TTMediaBot

A bot for music streaming to TeamTalk Servers.
https://ttmediabot.ru
MIT License
58 stars 65 forks source link

After Cache File is Modified, the Bot Is Prevented from Running because of It Not Properly Recognized (So It Seems) #120

Open ChrisDuffley opened 5 months ago

ChrisDuffley commented 5 months ago

As far as my limited Python knowledge goes it seems to me that after subsequent restarts of the bot, the cache file is not actually being loaded even though it clearly states it's the right one in the JSON file.

Here's what I get after running it with ./TTMediaBot.sh:

/home/chris/.local/lib/python3.10/site-packages/pydantic/_migration.py:283: UserWarning: `pydantic.error_wrappers:ValidationError` has been moved to `pydantic:ValidationError`.
  warnings.warn(f'`{import_path}` has been moved to `{new_location}`.')
Traceback (most recent call last):
  File "/home/chris/TTMediaBot/TTMediaBot.py", line 64, in <module>
    main()
  File "/home/chris/TTMediaBot/TTMediaBot.py", line 45, in main
    bot = Bot(config, cache, log)
  File "/home/chris/TTMediaBot/bot/__init__.py", line 60, in __init__
    self.cache_manager = cache.CacheManager(cache_file_name)
  File "/home/chris/TTMediaBot/bot/cache.py", line 42, in __init__
    self.data = cache_migrator.migrate(self, self._load())
  File "/home/chris/TTMediaBot/bot/cache.py", line 55, in _load
    return pickle.load(f)
  File "/home/chris/.local/lib/python3.10/site-packages/yt_dlp/utils/networking.py", line 70, in __setitem__
    super().__setitem__(key.title(), str(value).strip())
  File "/usr/lib/python3.10/collections/__init__.py", line 1109, in __setitem__
    self.data[key] = item
AttributeError: 'HTTPHeaderDict' object has no attribute 'data'

Running on a test instance of Ubuntu 22.04 before I upgrade my main server. Any reason why this is happening and can this be fixed?

ivnc commented 5 months ago

I also have various bots, running on Docker, which sometimes don't start correctly due to this issue. The only solution that has worked to me is to move or remove the cache file. Actually I was unable to figure out what exact change in cache contents causes this, because the issue doesn't happen every time.

cyrmax commented 5 months ago

Hi guys! Could you tell please what services do you use? I guess that this is only youtube and neither vk nor yam but just to be sure.

Also do you play just videos or also raw url streams?

Try to reproduce the issue please.

ivnc commented 4 months ago

Yes, only Youtube, the other services are directly disabled. I think that no matter if we search videos or we play raw URLs, but we don't play URLs very often. With regard to reproducing the issue, I have seen cache files only with one or two recent videos (only Youtube search, no URLs) causing this, and others, with the same number of videos, not, so...couldn't get the reproduction pattern so far.