JimmXinu / FanFicFare

FanFicFare is a tool for making eBooks from stories on fanfiction and other web sites.
Other
778 stars 165 forks source link

'cache_dir' is not defined #1104

Closed Groxx closed 2 months ago

Groxx commented 2 months ago

It's fairly likely that this is due to me mucking some config up, but the error looks like it's caused by incorrect code:

calibre, version 7.17.0
ERROR: Unhandled exception: <b>NameError</b>:name 'cache_dir' is not defined

calibre 7.17  embedded-python: True
Linux-6.8.0-41-generic-x86_64-with-glibc2.39 Linux ('64bit', 'ELF')
('Linux', '6.8.0-41-generic', '#41-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug  2 20:41:06 UTC 2024')
Python 3.11.5
Interface language: None
EXE path: /opt/calibre/bin/calibre
Successfully initialized third party plugins: FanFicFare (4, 38, 0) && KOReader Sync (0, 6, 7) && Reading List (1, 15, 4) && Standard Ebooks (1, 0, 0)
Traceback (most recent call last):
  File "calibre_plugins.fanficfare_plugin.fff_plugin", line 689, in get_urls_from_page_menu
    frompage = self.get_urls_from_page(url)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "calibre_plugins.fanficfare_plugin.fff_plugin", line 712, in get_urls_from_page
    return get_urls_from_page(url,configuration)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/geturls.py", line 44, in get_urls_from_page
    return adapter.get_urls_from_page(url,normalize)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/adapters/base_adapter.py", line 477, in get_urls_from_page
    data = self.get_request(url,usecache=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/requestable.py", line 119, in get_request
    return self.get_request_redirected(url,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/requestable.py", line 111, in get_request_redirected
    (data,rurl) = self.configuration.get_fetcher().get_request_redirected(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/configurable.py", line 1089, in get_fetcher
    self.browser_cache = BrowserCache(self.getConfig,
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/groxx/.config/calibre/plugins/FanFicFare.zip/fanficfare/browsercache/__init__.py", line 44, in __init__
    os.path.abspath(cache_dir))
                    ^^^^^^^^^
NameError: name 'cache_dir' is not defined

This is referring to the exception branch here: https://github.com/JimmXinu/FanFicFare/blob/711698620e45fd38aabe6b2811739e3946cf2cc9/fanficfare/browsercache/__init__.py#L34-L44 which doesn't have a defined cache_dir variable, nor do I see any globals in the module that it could be referencing....

...though it has been a while since I've done any Python, so apologies if I've missed something obvious.

JimmXinu commented 2 months ago

Apparently I didn't test turning on use_browser_cache:true without setting browser_cache_path when I made change 478d2e8f1738fda6b9482fdaad0f88a0a6d4faf3.

Groxx commented 2 months ago

Thank you!

This was apparently due to me using librewolf, which does not write caches to disk by default. (you can enable that in about:config, browser.cache.disk.enable -> change to true)

I'm now getting gio-launch-desktop errors instead, but it is reading the cache, and if I visit the URLs printed to calibre-debug it populates and reads the data. I'm still exploring the gio-launch-desktop thing but it looks like it's probably coming from Calibre, and probably not something that should be used in the first place (e.g. xdg-open is probably better)....

... but I'm probably gonna stop digging here tbh, unless anyone's particularly interested.