Browse Source

Change improve UI country and language from Trakt data.

Change include items without episode overview but language set to 'en'.
pull/1289/head
JackDandy 5 years ago
parent
commit
2d2b69033a
  1. 1
      CHANGES.md
  2. 18
      gui/slick/interfaces/default/home_browseShows.tmpl
  3. 12
      sickbeard/__init__.py
  4. 24
      sickbeard/webserve.py

1
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

18
gui/slick/interfaces/default/home_browseShows.tmpl

@ -370,6 +370,16 @@ $(document).ready(function(){
<div class="browse-image">
<a class="browse-image" href="<%= anon_url(this_show['url_src_db']) %>" target="_blank"
title="<span style='color: rgb(66, 139, 202)'>$re.sub(r'(?m)\s+\((?:19|20)\d\d\)\s*$', '', $title_html)</span>#if $this_show['genres']#<br /><div style='font-weight:bold'>(<em>$this_show['genres']</em>)</div>#end if#
#if $this_show.get('country') or $this_show.get('language')
<p style='line-height:15px;margin-bottom:2px'>
#if $this_show.get('country')
<span style='font-size:0.9em;color:#888'><em>Country:#if not $this_show.get('country_img')#&nbsp;$this_show.get('country').upper()#else#<img style='margin:0 0 2px 4px;width:16px;height:11px;vertical-align:middle' title='${this_show['country']}' src='$sbRoot/images/flags/${$this_show['country'].lower()}.png' width='16' height='11'>#end if#</em></span>
#end if
#if $this_show.get('language')
<span style='font-size:0.9em;color:#888#if $this_show.get('country')#;padding-left:6px#end if#'><em>Language:#if not $this_show.get('language_img')#&nbsp;$this_show.get('language')#else#<img style='margin:0 0 2px 4px;width:16px;height:11px;vertical-align:middle' title='${this_show['language']}' src='$sbRoot/images/flags/${$this_show['language'].lower()}.png' width='16' height='11'>#end if#</em></span>
#end if
</p>
#end if
<p style='margin:0 0 2px'>#echo re.sub(r'([,\.!][^,\.!]*?)$', '...', re.sub(r'([!\?\.])(?=\w)', r'\1 ', $overview)).replace('.....', '...')#</p>
<p><span style='font-weight:bold;font-size:0.9em;color:#888'><em>#if $kwargs and 'newseasons' == $mode#Air#else#First air#end if##echo ('s', 'ed')[$this_show['when_past']]#: $this_show['premiered_str']</em></span>
#if $this_show.get('ended_str')# - <span style='font-weight:bold;font-size:0.9em;color:#888'><em>Ended: $this_show['ended_str']</em></span>#end if#
@ -389,14 +399,6 @@ $(document).ready(function(){
<div class="show-title">
#echo ((re.sub(r'^((?:A(?!\s+to)n?)|The)\s(\w)', r'<span class="article">\1</span> \2', $this_show['title']), $this_show['title'])[$sg_var('SORT_ARTICLE')], '<span>&nbsp;</span>')['' == $this_show['title']]#
</div>
<div class="show-title">
#if $this_show['country']
<span>Country:</span><img class="flag" title="${this_show['country']}" src="$sbRoot/images/flags/${$this_show['country'].lower()}.png" width="16" height="11" />
#end if
#if $this_show['language']
<span>Language:</span><img class="flag" title="${this_show['language']}" src="$sbRoot/images/flags/${$this_show['language'].lower()}.png" width="16" height="11" />
#end if
</div>
#if 'Ani' not in $browse_type
<a class="show-toggle-hide" href="$sg_root/add-shows/show-toggle-hide?ids=$show_id" title="#echo ('H', 'Unh')[any($hide)]#ide"><i class="sgicon-delete"></i></a>
#end if

12
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

24
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)

Loading…
Cancel
Save