Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.0.33.1849 #34

Merged
merged 79 commits into from Dec 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
0c73de7
log opensubtitles response headers; add headers to response object
pannal Nov 5, 2017
fa42669
add opensubtitles VIP server handling
pannal Nov 6, 2017
fc3f5da
improve opensubtitles VIP server handling; set VIP to http by default…
pannal Nov 7, 2017
a7e022c
move VIP benefits note to VIP switch
pannal Nov 7, 2017
4d557be
Update VIP server to new URL; don't log out automatically
pannal Nov 8, 2017
5b8dfb4
update dev
pannal Nov 8, 2017
7ad49fa
opensubtitles: disable token reusage for now
pannal Nov 8, 2017
d5d6aa0
add throttling between searches in download_best_subtitles
pannal Nov 9, 2017
6264c21
fix #384
pannal Nov 9, 2017
3d119bc
fix typo
pannal Nov 9, 2017
6f3c806
fix adv_tag=None exception for external subtitles without advanced tag
pannal Nov 10, 2017
da59add
submod: drop "file" reference after modifying
pannal Nov 11, 2017
8c2effe
submod: add postprocessing mods
pannal Nov 11, 2017
327bb31
submod: color: apply colors at the end of processing, fixing possible…
pannal Nov 11, 2017
36cae63
submod: add remove_tags modification
pannal Nov 11, 2017
af6d7a1
update submod test and test.srt
pannal Nov 11, 2017
4102a1c
submod: removetags: show in menu
pannal Nov 11, 2017
cb00ab9
submod: make remove_tags configurable and a default mod
pannal Nov 11, 2017
fb722d0
opensubtitles: raise timeout to 10 seconds (was 4)
pannal Nov 11, 2017
1264cab
submod: remove_tags: fix newlines
pannal Nov 11, 2017
32c0f09
submod: HI: be even more aggressive at handling brackets
pannal Nov 11, 2017
2076a2c
submod: OCR: en: fix more "I" = "L" occurrences
pannal Nov 11, 2017
c9eb8bc
submod: OCR: en/hrv update OCR dicts
pannal Nov 11, 2017
e674132
bump dev
pannal Nov 11, 2017
ee02bdb
advanced menu: speed up batch mods
pannal Nov 11, 2017
8303af2
add generic get_part function; add fixme
pannal Nov 11, 2017
332d41f
add fixme
pannal Nov 11, 2017
f6ee6d4
remove resolved fixme
pannal Nov 11, 2017
931c224
submod: remove_tags: make non-default
pannal Nov 11, 2017
9dec7e4
bump dev
pannal Nov 11, 2017
402cfc1
Update README.md
pannal Nov 11, 2017
18d22a7
#300 basic subtitle blacklist menu/storage implementation
pannal Nov 12, 2017
db2903e
#300 full subtitle blacklist integration
pannal Nov 12, 2017
8b0d359
Merge remote-tracking branch 'origin/develop-2.0' into develop-2.0
pannal Nov 12, 2017
3842182
remove debug prints
pannal Nov 12, 2017
7967292
bump dev
pannal Nov 12, 2017
38a8557
update user agent list
pannal Nov 12, 2017
3d7a452
fix #300 return empty dicts instead of None when in doubt
pannal Nov 12, 2017
2b73f63
#300 add blacklist_all endpoint for bookmarklet usage
pannal Nov 12, 2017
84436df
#300 add optional language to blacklist_all endpoint
pannal Nov 12, 2017
8927513
recently played: don't show anything but Movie and Episode items; inc…
pannal Nov 12, 2017
a341808
#300 add recently played blacklist endpoints
pannal Nov 12, 2017
9b894c2
add explicit force endpoint for item refresh
pannal Nov 12, 2017
27cc3bd
bump dev
pannal Nov 12, 2017
f4884f1
opensubtitles: try using previous token
pannal Nov 14, 2017
35eb037
bump dev
pannal Nov 19, 2017
cc6004e
add vip affiliate link
pannal Nov 20, 2017
f61bc3c
Update README.md
pannal Nov 20, 2017
579e3ca
potential fix for strptime threadpool error
pannal Nov 21, 2017
01288af
potential fix for unmatched language
pannal Nov 25, 2017
e4d990c
use babelfish language matching
pannal Nov 25, 2017
aa6efb7
fix detection of PMS media stream language codes
pannal Nov 25, 2017
37491c1
bump dev
pannal Nov 25, 2017
d836f8f
remove plex_activity logging handler
pannal Nov 25, 2017
c1838a3
correctly skip unwanted subtitle extensions in MissingSubtitles
pannal Nov 26, 2017
bd25238
add TEXT_SUBTITLE_EXTS to config and use the variable
pannal Nov 26, 2017
85adb6b
MissingSubtitles: honor treat undefined as first language properly
pannal Nov 26, 2017
19aa800
MissingSubtitles: streamline
pannal Nov 26, 2017
4b77e63
MissingSubtitles: more
pannal Nov 26, 2017
8d8ecfe
MissingSubtitles: remove obsolete var dec
pannal Nov 26, 2017
dc658db
scan_video: ensure checking lowercase stream codec name
pannal Nov 26, 2017
a72a885
use copy of lang list
pannal Nov 26, 2017
a8ceae9
create actual copies of Language instances before trying to modify them
pannal Nov 26, 2017
c861721
again
pannal Nov 26, 2017
5f50bd7
compare stringified languages when determining missing ones
pannal Nov 27, 2017
c8eae6d
compare stringified languages when determining missing ones
pannal Nov 27, 2017
9b558fc
deduplicate languages on MissingSubtitles
pannal Nov 27, 2017
b552f6f
more ietf stuff; keep the original country in an alpha3 mapping inste…
pannal Nov 27, 2017
52a6127
add IETF fixme
pannal Nov 27, 2017
faf7ced
remove debug print
pannal Nov 27, 2017
1125c5c
submod: common: remove "xxxx downloaded from yyyy" lines
pannal Dec 1, 2017
2dcf39e
submod: OCR: fix more broken "Hey"'s; fix WholeWord handling at begin…
pannal Dec 2, 2017
e7785f7
submod: do OCR fixes before HI; submod: OCR: fix broken HI tag colons
pannal Dec 2, 2017
0e6a4ac
bump dev to 2.0.33.1849
pannal Dec 2, 2017
12bdaa5
2.0.33.1849
pannal Dec 3, 2017
cde6153
2.0.33.1849
pannal Dec 3, 2017
b76f1ad
Merge branch 'develop-2.0'
pannal Dec 3, 2017
0561c2d
back from dev
pannal Dec 3, 2017
3a01890
Update README.md
pannal Dec 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,21 @@
2.0.29.1756
- core: don't fail on uppercase file extensions
- core: don't re-download a subtitle if we already downloaded one, it still physically exists and external subtitles are configured to be ignored
- core: fix VTT subtitle duplication
- core: if forced subtitles not explicitly wanted, ignore existing forced subtitles when searching
- core: add full IETF language support for `Treat languages with country attribute as ISO 639-1 (e.g. don't download pt-BR if pt subtitle exists)`-setting for embedded subtitles
- menu: remove buggy dynamic permission-based channel icon introduced in 1715
- menu: improve `Items with missing subtitles` menu usage and item display
- menu: `Advanced -> Get my logs` handle custom domains without port
- menu: correctly show country/script part of languages with such attributes (e.g. pt-BR)
- config: rename `Scan:` settings; make them better understandable and translatable
- config: rephrase IETF options as "languages with country attribute" (e.g. pt-BR)
- config: separate IETF options into how to display languages with country attribute and how they should be handled when searching/scanning (e.g. pt-BR)
- config: `Scheduler: Item age to be considered recent` now can go up to 12 weeks
- config: `Scheduler: Periodically search for recent items with missing subtitles` added `every 2 hours`
- submod: swe: add Ĺ to Å


2.0.26.1715
- core: submod: OCR fixes: swe: replace ĺ with å inside words
- core: fix handling of non-existant PMS audio_codec info
Expand Down
3 changes: 2 additions & 1 deletion Contents/Code/__init__.py
Expand Up @@ -193,7 +193,8 @@ def update(self, metadata, media, lang):

else:
# downloaded_subtitles = {subliminal.Video: [subtitle, subtitle, ...]}
downloaded_subtitles = download_best_subtitles(scanned_video_part_map, min_score=use_score)
downloaded_subtitles = download_best_subtitles(scanned_video_part_map, min_score=use_score,
throttle_time=self.debounce)
item_ids = get_media_item_ids(media, kind=self.agent_type)

downloaded_any = False
Expand Down
160 changes: 155 additions & 5 deletions Contents/Code/interface/item_details.py
@@ -1,6 +1,8 @@
# coding=utf-8
import os

from babelfish import Language

from sub_mod import SubtitleModificationsMenu
from menu_helpers import debounce, SubFolderObjectContainer, default_thumb, add_ignore_options, get_item_task_data, \
set_refresh_menu_state, route
Expand All @@ -9,7 +11,7 @@
from subzero.constants import PREFIX
from support.config import config
from support.helpers import timestamp, df, get_language, display_language
from support.items import get_item_kind_from_rating_key, get_item, get_current_sub
from support.items import get_item_kind_from_rating_key, get_item, get_current_sub, get_item_title
from support.plex_media import get_plex_metadata
from support.scanning import scan_videos
from support.scheduler import scheduler
Expand Down Expand Up @@ -149,13 +151,14 @@ def ItemDetailsMenu(rating_key, title=None, base_title=None, item_title=None, ra
return oc


@route(PREFIX + '/item/current_sub/{rating_key}/{part_id}', force=bool)
@route(PREFIX + '/item/current_sub/{rating_key}/{part_id}')
@debounce
def SubtitleOptionsMenu(**kwargs):
oc = SubFolderObjectContainer(title2=kwargs["title"], replace_parent=True)
oc = SubFolderObjectContainer(title2=unicode(kwargs["title"]), replace_parent=True)
rating_key = kwargs["rating_key"]
part_id = kwargs["part_id"]
language = kwargs["language"]
current_data = kwargs["current_data"]

current_sub, stored_subs, storage = get_current_sub(rating_key, part_id, language)
kwargs.pop("randomize")
Expand All @@ -179,7 +182,147 @@ def SubtitleOptionsMenu(**kwargs):
summary=u"Currently applied mods: %s" % (", ".join(current_sub.mods) if current_sub.mods else "none")
))

oc.add(DirectoryObject(
key=Callback(BlacklistSubtitleMenu, randomize=timestamp(), **kwargs),
title=u"Blacklist %s subtitle and search for a new one" % kwargs["language_name"],
summary=current_data
))

current_bl, subs = stored_subs.get_blacklist(part_id, language)
if current_bl:
oc.add(DirectoryObject(
key=Callback(ManageBlacklistMenu, randomize=timestamp(), **kwargs),
title=u"Manage blacklist (%s contained)" % len(current_bl),
summary=u"Inspect currently blacklisted subtitles"
))

storage.destroy()
return oc


@route(PREFIX + '/item/blacklist_recent/{language}')
@route(PREFIX + '/item/blacklist_recent')
def BlacklistRecentSubtitleMenu(**kwargs):
if "last_played_items" not in Dict or not Dict["last_played_items"]:
return

rating_key = Dict["last_played_items"][0]
kwargs["rating_key"] = rating_key
return BlacklistAllPartsSubtitleMenu(**kwargs)


@route(PREFIX + '/item/blacklist_all/{rating_key}/{language}')
@route(PREFIX + '/item/blacklist_all/{rating_key}')
def BlacklistAllPartsSubtitleMenu(**kwargs):
rating_key = kwargs.get("rating_key")
language = kwargs.get("language")
if language:
language = Language.fromietf(language)

item = get_item(rating_key)

if not item:
return

item_title = get_item_title(item)

subtitle_storage = get_subtitle_storage()
stored_subs = subtitle_storage.load_or_new(item)
for part_id, languages in stored_subs.parts.iteritems():
sub_dict = languages
if language:
key = str(language)
if key not in sub_dict:
continue

sub_dict = {key: sub_dict[key]}

for language, subs in sub_dict.iteritems():
if "current" in subs:
stored_subs.blacklist(part_id, language, subs["current"])
Log.Info("Added %s to blacklist", subs["current"])

subtitle_storage.save(stored_subs)
subtitle_storage.destroy()

return RefreshItem(rating_key=rating_key, item_title=item_title, force=True, randomize=timestamp(), timeout=30000)


def blacklist(rating_key, part_id, language):
current_sub, stored_subs, storage = get_current_sub(rating_key, part_id, language)
if not current_sub:
return

stored_subs.blacklist(part_id, language, current_sub.key)
storage.save(stored_subs)
storage.destroy()

Log.Info("Added %s to blacklist", current_sub.key)

return True


@route(PREFIX + '/item/blacklist/{rating_key}/{part_id}')
@debounce
def BlacklistSubtitleMenu(**kwargs):
rating_key = kwargs["rating_key"]
part_id = kwargs["part_id"]
language = kwargs["language"]
item_title = kwargs["item_title"]

blacklist(rating_key, part_id, language)
kwargs.pop("randomize")

return RefreshItem(rating_key=rating_key, item_title=item_title, force=True, randomize=timestamp(), timeout=30000)


@route(PREFIX + '/item/manage_blacklist/{rating_key}/{part_id}', force=bool)
@debounce
def ManageBlacklistMenu(**kwargs):
oc = SubFolderObjectContainer(title2=unicode(kwargs["title"]), replace_parent=True)
rating_key = kwargs["rating_key"]
part_id = kwargs["part_id"]
language = kwargs["language"]
remove_sub_key = kwargs.pop("remove_sub_key", None)

current_sub, stored_subs, storage = get_current_sub(rating_key, part_id, language)
current_bl, subs = stored_subs.get_blacklist(part_id, language)

if remove_sub_key:
remove_sub_key = tuple(remove_sub_key.split("__"))
stored_subs.blacklist(part_id, language, remove_sub_key, add=False)
storage.save(stored_subs)
Log.Info("Removed %s from blacklist", remove_sub_key)

kwargs.pop("randomize")

oc.add(DirectoryObject(
key=Callback(ItemDetailsMenu, rating_key=kwargs["rating_key"], item_title=kwargs["item_title"],
title=kwargs["title"], randomize=timestamp()),
title=u"< Back to %s" % kwargs["title"],
summary=kwargs["current_data"],
thumb=default_thumb
))

def sorter(pair):
# thanks RestrictedModule parser for messing with lambda (x, y)
return pair[1]["date_added"]

for sub_key, data in sorted(current_bl.iteritems(), key=sorter, reverse=True):
provider_name, subtitle_id = sub_key
title = u"%s, %s (added: %s, %s), Language: " \
u"%s, Score: %i, Storage: %s" % (provider_name, subtitle_id, df(data["date_added"]),
current_sub.get_mode_verbose(data["mode"]),
display_language(Language.fromietf(language)), data["score"],
data["storage_type"])
oc.add(DirectoryObject(
key=Callback(ManageBlacklistMenu, remove_sub_key="__".join(sub_key), randomize=timestamp(), **kwargs),
title=title,
summary=u"Remove subtitle from blacklist"
))

storage.destroy()

return oc


Expand Down Expand Up @@ -264,11 +407,18 @@ def ListAvailableSubsForItemMenu(rating_key=None, part_id=None, title=None, item
if not search_results or search_results == "found_none":
return oc

current_sub, stored_subs, storage = get_current_sub(rating_key, part_id, language)
current_bl, subs = stored_subs.get_blacklist(part_id, language)

seen = []
for subtitle in search_results:
if subtitle.id in seen:
continue

bl_addon = ""
if (str(subtitle.provider_name), str(subtitle.id)) in current_bl:
bl_addon = "Blacklisted "

wrong_fps_addon = ""
if subtitle.wrong_fps:
if plex_part:
Expand All @@ -279,8 +429,8 @@ def ListAvailableSubsForItemMenu(rating_key=None, part_id=None, title=None, item
oc.add(DirectoryObject(
key=Callback(TriggerDownloadSubtitle, rating_key=rating_key, randomize=timestamp(), item_title=item_title,
subtitle_id=str(subtitle.id), language=language),
title=u"%s: %s, score: %s%s" % ("Available" if current_id != subtitle.id else "Current",
subtitle.provider_name, subtitle.score, wrong_fps_addon),
title=u"%s%s: %s, score: %s%s" % (bl_addon, "Available" if current_id != subtitle.id else "Current",
subtitle.provider_name, subtitle.score, wrong_fps_addon),
summary=u"Release: %s, Matches: %s" % (subtitle.release_info, ", ".join(subtitle.matches)),
thumb=default_thumb
))
Expand Down
14 changes: 4 additions & 10 deletions Contents/Code/interface/main.py
Expand Up @@ -2,11 +2,10 @@

from subzero.constants import PREFIX, TITLE, ART
from support.config import config
from support.helpers import pad_title, timestamp, df, get_plex_item_display_title, display_language
from support.helpers import pad_title, timestamp, df, display_language
from support.scheduler import scheduler
from support.ignore import ignore_list
from support.items import get_item_thumb, get_on_deck_items, get_all_items, get_items_info, get_item, \
get_item_kind_from_item
from support.items import get_item_thumb, get_on_deck_items, get_all_items, get_items_info, get_item, get_item_title
from menu_helpers import main_icon, debounce, SubFolderObjectContainer, default_thumb, dig_tree, add_ignore_options, \
ObjectContainer, route, handler
from item_details import ItemDetailsMenu
Expand Down Expand Up @@ -186,15 +185,10 @@ def RecentlyPlayedMenu():
if not item:
continue

kind = get_item_kind_from_item(item)
if kind not in ("episode", "movie"):
if getattr(getattr(item, "__class__"), "__name__") not in ("Episode", "Movie"):
continue

if kind == "episode":
item_title = get_plex_item_display_title(item, "show", parent=item.season, section_title=None,
parent_title=item.show.title)
else:
item_title = get_plex_item_display_title(item, kind, section_title=None)
item_title = get_item_title(item)

oc.add(DirectoryObject(
title=item_title,
Expand Down
3 changes: 2 additions & 1 deletion Contents/Code/interface/refresh_item.py
Expand Up @@ -6,7 +6,8 @@
from support.helpers import timestamp


@route(PREFIX + '/item/{rating_key}')
@route(PREFIX + '/item/refresh/{rating_key}/force', force=True)
@route(PREFIX + '/item/refresh/{rating_key}')
@debounce
def RefreshItem(rating_key=None, came_from="/recent", item_title=None, force=False, refresh_kind=None,
previous_rating_key=None, timeout=8000, randomize=None, trigger=True):
Expand Down
10 changes: 8 additions & 2 deletions Contents/Code/support/config.py
Expand Up @@ -25,6 +25,7 @@

SUBTITLE_EXTS = ['utf', 'utf8', 'utf-8', 'srt', 'smi', 'rt', 'ssa', 'aqt', 'jss', 'ass', 'idx', 'sub', 'txt', 'psb',
'vtt']
TEXT_SUBTITLE_EXTS = ("srt", "ass", "ssa", "vtt")
VIDEO_EXTS = ['3g2', '3gp', 'asf', 'asx', 'avc', 'avi', 'avs', 'bivx', 'bup', 'divx', 'dv', 'dvr-ms', 'evo', 'fli',
'flv',
'm2t', 'm2ts', 'm2v', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mts', 'nsv', 'nuv', 'ogm', 'ogv', 'tp',
Expand Down Expand Up @@ -84,6 +85,7 @@ class Config(object):
sections = None
enabled_sections = None
remove_hi = False
remove_tags = False
fix_ocr = False
fix_common = False
colors = ""
Expand All @@ -99,7 +101,7 @@ class Config(object):
activity_mode = None
no_refresh = False

store_recently_played_amount = 20
store_recently_played_amount = 40

initialized = False

Expand Down Expand Up @@ -148,6 +150,7 @@ def initialize(self):
self.permissions_ok = self.check_permissions()
self.notify_executable = self.check_notify_executable()
self.remove_hi = cast_bool(Prefs['subtitles.remove_hi'])
self.remove_tags = cast_bool(Prefs['subtitles.remove_tags'])
self.fix_ocr = cast_bool(Prefs['subtitles.fix_ocr'])
self.fix_common = cast_bool(Prefs['subtitles.fix_common'])
self.colors = Prefs['subtitles.colors'] if Prefs['subtitles.colors'] != "don't change" else None
Expand Down Expand Up @@ -501,7 +504,8 @@ def get_provider_settings(self):
'opensubtitles': {'username': Prefs['provider.opensubtitles.username'],
'password': Prefs['provider.opensubtitles.password'],
'use_tag_search': cast_bool(Prefs['provider.opensubtitles.use_tags']),
'only_foreign': cast_bool(Prefs['subtitles.only_foreign'])
'only_foreign': cast_bool(Prefs['subtitles.only_foreign']),
'is_vip': cast_bool(Prefs['provider.opensubtitles.is_vip'])
},
'podnapisi': {
'only_foreign': cast_bool(Prefs['subtitles.only_foreign'])
Expand Down Expand Up @@ -564,6 +568,8 @@ def get_default_mods(self):
mods = []
if self.remove_hi:
mods.append("remove_HI")
if self.remove_tags:
mods.append("remove_tags")
if self.fix_ocr:
mods.append("OCR_fixes")
if self.fix_common:
Expand Down