diff --git a/CHANGES.md b/CHANGES.md
index 4b2664e..077648b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,6 +2,7 @@
* Add menu Shows/"Metacritic Cards"
* Add menu Shows/"TV Calendar Cards"
+* Add country and language to Shows/"Trakt Cards"
* Change make web UI calls async so that, for example, process media will not block page requests
* Change improve speed of backlog overview
* Fix the missing snatched low quality on backlog overview
diff --git a/gui/slick/interfaces/default/home_browseShows.tmpl b/gui/slick/interfaces/default/home_browseShows.tmpl
index 1289530..2df935b 100644
--- a/gui/slick/interfaces/default/home_browseShows.tmpl
+++ b/gui/slick/interfaces/default/home_browseShows.tmpl
@@ -370,6 +370,16 @@ $(document).ready(function(){
-
- #if $this_show['country']
-
Country:![${this_show['country']}]($sbRoot/images/flags/${$this_show['country'].lower()}.png)
- #end if
- #if $this_show['language']
-
Language:![${this_show['language']}]($sbRoot/images/flags/${$this_show['language'].lower()}.png)
- #end if
-
#if 'Ani' not in $browse_type
#end if
diff --git a/sickbeard/__init__.py b/sickbeard/__init__.py
index 0379d75..be537a6 100755
--- a/sickbeard/__init__.py
+++ b/sickbeard/__init__.py
@@ -56,7 +56,7 @@ from adba.aniDBerrors import AniDBError
from configobj import ConfigObj
from libtrakt import TraktAPI
-from _23 import b64encodestring, filter_iter, list_items, map_list
+from _23 import b64encodestring, filter_iter, list_items, map_list, scandir
from six import iteritems, PY2, string_types
import sg_helpers
@@ -594,6 +594,7 @@ __INITIALIZED__ = False
__INIT_STAGE__ = 0
MEMCACHE = {}
+MEMCACHE_FLAG_IMAGES = {}
def get_backlog_cycle_time():
@@ -1420,7 +1421,7 @@ def init_stage_1(console_logging):
def init_stage_2():
# Misc
- global __INITIALIZED__, MEMCACHE, RECENTSEARCH_STARTUP
+ global __INITIALIZED__, MEMCACHE, MEMCACHE_FLAG_IMAGES, RECENTSEARCH_STARTUP
# Schedulers
# global traktCheckerScheduler
global recentSearchScheduler, backlogSearchScheduler, showUpdateScheduler, \
@@ -1585,6 +1586,13 @@ def init_stage_2():
run_delay=datetime.timedelta(minutes=5),
threadName='PLEXWATCHEDSTATE')
+ try:
+ for f in ek.ek(scandir, ek.ek(os.path.join, PROG_DIR, 'gui', GUI_NAME, 'images', 'flags')):
+ if f.is_file():
+ MEMCACHE_FLAG_IMAGES[ek.ek(os.path.splitext, f.name)[0].lower()] = True
+ except (BaseException, Exception):
+ pass
+
__INITIALIZED__ = True
return True
diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py
index ece6d51..84a4846 100644
--- a/sickbeard/webserve.py
+++ b/sickbeard/webserve.py
@@ -4311,7 +4311,13 @@ class AddShows(Home):
ignore = r'''
((bbc|channel\s*?5.*?|itv)\s*?(drama|documentaries))|bbc\s*?(comedy|music)|music\s*?specials|tedtalks
'''
- if re.search(ignore, item['show']['title'].strip(), re.I | re.X):
+ language = (item.get('show', {}).get('language') or '').lower()
+ language_en = 'en' == language
+ country = (item.get('show', {}).get('country') or '').lower()
+ country_ok = country in ('uk', 'gb', 'ie', 'ca', 'us', 'au', 'nz', 'za')
+ if re.search(ignore, item['show']['title'].strip(), re.I | re.X) or \
+ (not language_en and not country_ok) or \
+ not (item.get('show', {}).get('overview') or item.get('episode', {}).get('overview')):
continue
try:
dt = dateutil.parser.parse(item['show']['first_aired'])
@@ -4329,26 +4335,28 @@ class AddShows(Home):
traktid = item.get('show', {}).get('ids', {}).get('trakt', 0)
images = dict(poster=dict(thumb='imagecache?path=browse/thumb/trakt&filename=%s&tmdbid=%s&tvdbid=%s' %
('%s.jpg' % traktid, tmdbid, tvdbid)))
-
filtered.append(dict(
premiered=dt_ordinal,
premiered_str=dt_string,
when_past=dt_ordinal < datetime.datetime.now().toordinal(), # air time not yet available 16.11.2015
episode_number='' if 'episode' not in item else item['episode']['number'] or 1,
- episode_overview=('' if 'episode' not in item else
- item['episode']['overview'].strip() or ''),
+ episode_overview=(
+ '' if 'episode' not in item else
+ '' if None is item.get('episode', {}).get('overview') and (language_en or country_ok)
+ else item['episode']['overview'].strip() or ''),
episode_season='' if 'episode' not in item else item['episode']['season'] or 1,
genres=('' if 'genres' not in item['show'] else
', '.join(['%s' % v for v in item['show']['genres']])),
ids=item['show']['ids'],
images=images,
- overview=('' if 'overview' not in item['show'] or None is item['show']['overview'] else
- item['show']['overview'].strip()),
+ overview=(item.get('show', {}).get('overview') or '').strip(),
rating=0 < item['show'].get('rating', 0) and
('%.2f' % (item['show'].get('rating') * 10)).replace('.00', '') or 0,
title=item['show']['title'].strip(),
- language=item['show']['language'],
- country=item['show']['country'],
+ language=language,
+ language_img=not language_en and sickbeard.MEMCACHE_FLAG_IMAGES.get(language, False),
+ country=country,
+ country_img=sickbeard.MEMCACHE_FLAG_IMAGES.get(country, False),
url_src_db='https://trakt.tv/shows/%s' % item['show']['ids']['slug'],
url_tvdb=('', sickbeard.TVInfoAPI(TVINFO_TVDB).config['show_url'] % item['show']['ids']['tvdb'])[
isinstance(item['show']['ids']['tvdb'], integer_types)