mirror of
https://github.com/evilhero/mylar
synced 2024-12-22 15:52:47 +00:00
21eee17344
torrents will now properly hide torrent information, IMP: Specified daemon port for deluge as an on-screen tip for more detail, IMP: Added 100,200,ALL as viewable watchlist views, FIX: When viewing pullist and annual integration enabled, if annual was present would incorrectly link to invalid annual series instead of the actual series itself, IMP: Added more detail error messages to metatagging errors and better handling of stranded files during cleanup, IMP: Improved some handling for weekly pull-list one-off's and refactored the nzb/oneoff post-processing into a seperate function for future callables, Moved all the main url locations for public torrent sites to the init module so that it can be cascaded down for use in other modules instead as a global, IMP: Added a 'deep_search_32p' variable in the config.ini for specific usage with 32p, where if there is more than one result will dig deeper into each result to try and figure out if there are series matches, as opposed to the default where it will only use ref32p table if available or just the first hit in a multiple series search results and ignore the remainder, FIX:Fixed some unknown characters appearing in the pullist due to unicode-related conversion problems, FIX: fixed some special cases of file parsing errors due to Volume label being named different than expected, FIX: Added a 3s pause between experimental searches to try and not hit their frequency limitation, IMP: Weekly Pullist One-off's will now show status of Snatched/Downloaded as required, FIX: Fixed some deluge parameter problems when using auto-snatch torrent script/option, IMP: Changed the downlocation in the auto-snatch option to an env variable instead of being passed to avoid unicode-related problems, FIX: Fixed some magnet-related issues for torrents when using a watchdir + TPSE, FIX: Added more verbose error message for rtorrent connection issues, FIX: Could not connect to rtorrent client if no username/password were provided, IMP: Set the db updater to run every 5 minutes on the watchlist, automatically refreshing the oldest updated series each time that is more than 5 hours old (force db update from the activity/job schedulers page will run the db updater against the entire watchlist in sequence), IMP: Attempt to handle long paths in windows (ie. > 256c) by prepending the unicode windows api character to the import a directory path (windows only), IMP: When manual metatagging a series, will update the series after all the metatagging has been completed as opposed to after each issue, IMP: Will now display available inkdrops on Config/Search Providers tab when using 32P (future will utilize/indicate inkdrop threshold when downloading)
93 lines
3.1 KiB
Python
93 lines
3.1 KiB
Python
try:
|
|
import _winreg as winreg
|
|
except ImportError:
|
|
import winreg
|
|
|
|
from tzlocal.windows_tz import win_tz
|
|
import pytz
|
|
|
|
_cache_tz = None
|
|
|
|
def valuestodict(key):
|
|
"""Convert a registry key's values to a dictionary."""
|
|
dict = {}
|
|
size = winreg.QueryInfoKey(key)[1]
|
|
for i in range(size):
|
|
data = winreg.EnumValue(key, i)
|
|
dict[data[0]] = data[1]
|
|
return dict
|
|
|
|
def get_localzone_name():
|
|
# Windows is special. It has unique time zone names (in several
|
|
# meanings of the word) available, but unfortunately, they can be
|
|
# translated to the language of the operating system, so we need to
|
|
# do a backwards lookup, by going through all time zones and see which
|
|
# one matches.
|
|
handle = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
|
|
|
|
TZLOCALKEYNAME = r"SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
|
|
localtz = winreg.OpenKey(handle, TZLOCALKEYNAME)
|
|
keyvalues = valuestodict(localtz)
|
|
localtz.Close()
|
|
if 'TimeZoneKeyName' in keyvalues:
|
|
# Windows 7 (and Vista?)
|
|
|
|
# For some reason this returns a string with loads of NUL bytes at
|
|
# least on some systems. I don't know if this is a bug somewhere, I
|
|
# just work around it.
|
|
tzkeyname = keyvalues['TimeZoneKeyName'].split('\x00', 1)[0]
|
|
else:
|
|
# Windows 2000 or XP
|
|
|
|
# This is the localized name:
|
|
tzwin = keyvalues['StandardName']
|
|
|
|
# Open the list of timezones to look up the real name:
|
|
TZKEYNAME = r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones"
|
|
tzkey = winreg.OpenKey(handle, TZKEYNAME)
|
|
|
|
# Now, match this value to Time Zone information
|
|
tzkeyname = None
|
|
for i in range(winreg.QueryInfoKey(tzkey)[0]):
|
|
subkey = winreg.EnumKey(tzkey, i)
|
|
sub = winreg.OpenKey(tzkey, subkey)
|
|
data = valuestodict(sub)
|
|
sub.Close()
|
|
try:
|
|
if data['Std'] == tzwin:
|
|
tzkeyname = subkey
|
|
break
|
|
except KeyError:
|
|
# This timezone didn't have proper configuration.
|
|
# Ignore it.
|
|
pass
|
|
|
|
tzkey.Close()
|
|
handle.Close()
|
|
|
|
if tzkeyname is None:
|
|
raise LookupError('Can not find Windows timezone configuration')
|
|
|
|
timezone = win_tz.get(tzkeyname)
|
|
if timezone is None:
|
|
# Nope, that didn't work. Try adding "Standard Time",
|
|
# it seems to work a lot of times:
|
|
timezone = win_tz.get(tzkeyname + " Standard Time")
|
|
|
|
# Return what we have.
|
|
if timezone is None:
|
|
raise pytz.UnknownTimeZoneError('Can not find timezone ' + tzkeyname)
|
|
|
|
return timezone
|
|
|
|
def get_localzone():
|
|
"""Returns the zoneinfo-based tzinfo object that matches the Windows-configured timezone."""
|
|
global _cache_tz
|
|
if _cache_tz is None:
|
|
_cache_tz = pytz.timezone(get_localzone_name())
|
|
return _cache_tz
|
|
|
|
def reload_localzone():
|
|
"""Reload the cached localzone. You need to call this if the timezone has changed."""
|
|
global _cache_tz
|
|
_cache_tz = pytz.timezone(get_localzone_name())
|