Skip to content

Commit

Permalink
Merge pull request #10405 from pymedusa/release/release-0.5.25
Browse files Browse the repository at this point in the history
Release/release 0.5.25
  • Loading branch information
p0psicles authored Mar 8, 2022
2 parents 4908f30 + c5072b6 commit 5de42f0
Show file tree
Hide file tree
Showing 107 changed files with 2,090 additions and 784 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## 0.5.25 (08-03-2022)

#### New Features
- New indexer: Added support for adding shows from Imdb ([3603](https://github.com/pymedusa/Medusa/pull/3603))

#### Improvements
- Enhanced test guessit tool ([10357](https://github.com/pymedusa/Medusa/pull/10357))
- Discord notifier: added ability to override avatar ([10351](https://github.com/pymedusa/Medusa/pull/10351))
- Purge recommended shows cache after x days ([10352](https://github.com/pymedusa/Medusa/pull/10352))
- Added a "load more" button to recommended shows ([10380](https://github.com/pymedusa/Medusa/pull/10380))
- Improve menu layout on mobile ([10386](https://github.com/pymedusa/Medusa/pull/10386))

#### Fixes
- Fix saving specific post-processing method ([10350](https://github.com/pymedusa/Medusa/pull/10350))
- Fix pasing torrent size when using torznab provider that have torrent_size available in the attrs. ([10365](https://github.com/pymedusa/Medusa/pull/10365))
- Fix provider MoreThenTv ([10391](https://github.com/pymedusa/Medusa/pull/10391))
- Fix Manage mass-update: Starting the refresh action ([10377](https://github.com/pymedusa/Medusa/pull/10377))

## 0.5.24 (15-02-2022)

#### Improvements
Expand Down
5 changes: 5 additions & 0 deletions medusa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ def initialize(self, console_logging=True):
check_setting_int(app.CFG, 'Discord', 'discord_notify_onsubtitledownload', 0))
app.DISCORD_WEBHOOK = check_setting_str(app.CFG, 'Discord', 'discord_webhook', '', censor_log='normal')
app.DISCORD_TTS = check_setting_bool(app.CFG, 'Discord', 'discord_tts', 0)
app.DISCORD_OVERRIDE_AVATAR = check_setting_bool(app.CFG, 'Discord', 'override_avatar', 0)
app.DISCORD_NAME = check_setting_str(app.CFG, 'Discord', 'discord_name', '', censor_log='normal')

app.USE_PROWL = bool(check_setting_int(app.CFG, 'Prowl', 'use_prowl', 0))
Expand Down Expand Up @@ -1049,6 +1050,7 @@ def initialize(self, console_logging=True):
0, min(23, check_setting_int(app.CFG, 'Recommended', 'recommended_show_update_hour', app.DEFAULT_RECOMMENDED_SHOW_UPDATE_HOUR))
)
app.CACHE_RECOMMENDED_TRAKT_LISTS = check_setting_list(app.CFG, 'Recommended', 'trakt_lists', app.CACHE_RECOMMENDED_TRAKT_LISTS)
app.CACHE_RECOMMENDED_PURGE_AFTER_DAYS = check_setting_int(app.CFG, 'Recommended', 'purge_after_days', 180)

# Initialize trakt config path.
trakt.core.CONFIG_PATH = os.path.join(app.CACHE_DIR, '.pytrakt.json')
Expand Down Expand Up @@ -1199,6 +1201,7 @@ def initialize(self, console_logging=True):
# initialize the recommended shows database
recommended_db_con = db.DBConnection('recommended.db')
db.upgradeDatabase(recommended_db_con, recommended_db.InitialSchema)
db.sanityCheckDatabase(recommended_db_con, recommended_db.RecommendedSanityCheck)

# Performs a vacuum on cache.db
logger.debug(u'Performing a vacuum on the CACHE database')
Expand Down Expand Up @@ -1748,6 +1751,7 @@ def save_config():
new_config['Recommended']['cache_anilist'] = app.CACHE_RECOMMENDED_ANILIST
new_config['Recommended']['recommended_show_update_hour'] = int(app.RECOMMENDED_SHOW_UPDATE_HOUR)
new_config['Recommended']['trakt_lists'] = app.CACHE_RECOMMENDED_TRAKT_LISTS
new_config['Recommended']['purge_after_days'] = int(app.CACHE_RECOMMENDED_PURGE_AFTER_DAYS)

new_config['Blackhole'] = {}
new_config['Blackhole']['nzb_dir'] = app.NZB_DIR
Expand Down Expand Up @@ -1907,6 +1911,7 @@ def save_config():
new_config['Discord']['discord_notify_onsubtitledownload'] = int(app.DISCORD_NOTIFY_ONSUBTITLEDOWNLOAD)
new_config['Discord']['discord_webhook'] = app.DISCORD_WEBHOOK
new_config['Discord']['discord_tts'] = int(app.DISCORD_TTS)
new_config['Discord']['override_avatar'] = int(app.DISCORD_OVERRIDE_AVATAR)
new_config['Discord']['discord_name'] = app.DISCORD_NAME

new_config['Prowl'] = {}
Expand Down
2 changes: 2 additions & 0 deletions medusa/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ def __init__(self):
self.DISCORD_NAME = 'pymedusa'
self.DISCORD_AVATAR_URL = '{base_url}/images/ico/favicon-144.png'.format(base_url=self.BASE_PYMEDUSA_URL)
self.DISCORD_TTS = False
self.DISCORD_OVERRIDE_AVATAR = False

self.USE_PROWL = False
self.PROWL_NOTIFY_ONSNATCH = False
Expand Down Expand Up @@ -727,6 +728,7 @@ def __init__(self):
'trending', 'popular', 'anticipated', 'collected',
'watched', 'played', 'recommendations', 'newshow', 'newseason'
]
self.CACHE_RECOMMENDED_PURGE_AFTER_DAYS = 180

def _init_scheduler(self, app_prop=None, scheduler=None, enabled=None):
from medusa.logger.adapters.style import BraceAdapter
Expand Down
25 changes: 24 additions & 1 deletion medusa/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@

from dateutil import parser


from medusa import app, ws
from medusa.common import (
MULTI_EP_RESULT,
Quality,
SEASON_RESULT,
)
from medusa.helper.common import sanitize_filename
from medusa.logger.adapters.style import BraceAdapter
from medusa.search import SearchType

from six import itervalues

from trans import trans

log = BraceAdapter(logging.getLogger(__name__))
log.logger.addHandler(logging.NullHandler())

Expand Down Expand Up @@ -365,6 +369,22 @@ def select_series(self, all_series):
search_results = []
series_names = []

def searchterm_in_result(search_term, search_result):
norm_search_term = sanitize_filename(search_term.lower())
norm_result = sanitize_filename(search_result.lower())

if norm_search_term in norm_result:
return True

# translates national characters into similar sounding latin characters
# For ex. Физрук -> Fizruk
search_term_alpha = trans(self.config['searchterm'])

if search_term_alpha != search_term and search_term_alpha in norm_result:
return True

return False

# get all available shows
if all_series:
if 'searchterm' in self.config:
Expand All @@ -382,8 +402,11 @@ def select_series(self, all_series):
if search_term.isdigit():
series_names.append(search_term)

if search_term.startswith('tt'):
series_names.append(search_term)

for name in series_names:
if search_term.lower() in name.lower():
if searchterm_in_result(search_term, name):
if 'firstaired' not in cur_show:
default_date = parser.parse('1900-01-01').date()
cur_show['firstaired'] = default_date.strftime(dateFormat)
Expand Down
5 changes: 3 additions & 2 deletions medusa/clients/torrent/qbittorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,9 @@ def get_status(self, info_hash):
# Store destination
client_status.destination = torrent['save_path']

# Store resource
client_status.resource = basename(torrent['content_path'])
if torrent.get('content_path'):
# Store resource
client_status.resource = basename(torrent['content_path'])

log.info('Qbittorrent torrent: [{name}] using state: [{state}]', {
'name': client_status.resource, 'state': torrent['state']
Expand Down
2 changes: 1 addition & 1 deletion medusa/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
log.logger.addHandler(logging.NullHandler())

INSTANCE_ID = text_type(uuid.uuid1())
VERSION = '0.5.24'
VERSION = '0.5.25'

USER_AGENT = 'Medusa/{version} ({system}; {release}; {instance})'.format(
version=VERSION, system=platform.system(), release=platform.release(),
Expand Down
20 changes: 20 additions & 0 deletions medusa/databases/cache_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
# Add new migrations at the bottom of the list
# and subclass the previous migration.
class InitialSchema(db.SchemaUpgrade):
"""Cache.db initial schema class."""

def test(self):
"""Test db version."""
return self.hasTable('db_version')

def execute(self):
"""Execute."""
queries = [
('CREATE TABLE lastUpdate (provider TEXT, time NUMERIC);',),
('CREATE TABLE lastSearch (provider TEXT, time NUMERIC);',),
Expand Down Expand Up @@ -229,3 +233,19 @@ def test(self):
def execute(self):
self.connection.action('DROP TABLE IF EXISTS scene_exceptions;')
self.inc_major_version()


class AddSeasonUpdatesTable(RemoveSceneExceptionsTable): # pylint:disable=too-many-ancestors
def test(self):
return self.hasTable('season_updates')

def execute(self):
self.connection.action(
"""CREATE TABLE "season_updates" (
`season_updates_id` INTEGER,
`indexer` INTEGER NOT NULL,
`series_id` INTEGER NOT NULL,
`season` INTEGER,
`time` INTEGER,
PRIMARY KEY(season_updates_id))"""
)
8 changes: 8 additions & 0 deletions medusa/databases/main_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def check(self):
self.fix_show_nfo_lang()
self.fix_subtitle_reference()
self.clean_null_indexer_mappings()
self.clean_imdb_tt_ids()

def clean_null_indexer_mappings(self):
log.debug(u'Checking for null indexer mappings')
Expand Down Expand Up @@ -219,6 +220,13 @@ def fix_subtitles_codes(self):
def fix_show_nfo_lang(self):
self.connection.action("UPDATE tv_shows SET lang = '' WHERE lang = 0 OR lang = '0';")

def clean_imdb_tt_ids(self):
# Get all records with 'tt'
log.debug(u'Cleaning indexer_mapping table, removing references to same indexer')
self.connection.action('DELETE from indexer_mapping WHERE indexer = mindexer')
log.debug(u'Cleaning indexer_mapping table from tt indexer ids')
self.connection.action("DELETE FROM indexer_mapping where indexer_id like '%tt%' or mindexer_id like '%tt%'")


# ======================
# = Main DB Migrations =
Expand Down
13 changes: 13 additions & 0 deletions medusa/databases/recommended_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
log.logger.addHandler(logging.NullHandler())


class RecommendedSanityCheck(db.DBSanityCheck):
"""Sanity check class."""

def check(self):
"""Check functions."""
self.remove_imdb_tt()

def remove_imdb_tt(self):
"""Remove tt from imdb id's."""
log.debug(u'Remove shows added with an incorrect imdb id.')
self.connection.action("DELETE FROM shows WHERE source = 10 AND series_id like '%tt%'")


# Add new migrations at the bottom of the list
# and subclass the previous migration.
class InitialSchema(db.SchemaUpgrade):
Expand Down
21 changes: 20 additions & 1 deletion medusa/generic_update_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import logging
from datetime import date, datetime, timedelta

from medusa import app, ws
from medusa import app, db, ws
from medusa.helper.exceptions import CantUpdateRecommendedShowsException
from medusa.logger.adapters.style import BraceAdapter
from medusa.queues import generic_queue
Expand Down Expand Up @@ -136,6 +136,23 @@ def __init__(self, update_action):
self.started = False
self.success = False

def _purge_after_days(self):
log.info('Purge shows that have been added more then {days} ago', {'days': app.CACHE_RECOMMENDED_PURGE_AFTER_DAYS})
if not app.CACHE_RECOMMENDED_PURGE_AFTER_DAYS:
return

sql = """
DELETE FROM shows
WHERE added < datetime('now', '-{days} days')
""".format(days=app.CACHE_RECOMMENDED_PURGE_AFTER_DAYS)
params = []

if self.recommended_list != GenericQueueActions.UPDATE_RECOMMENDED_LIST_ALL:
sql += ' AND source = ?'
params = [self.recommended_list]

db.DBConnection('recommended.db').action(sql, params)

def _get_trakt_shows(self):
"""Get Trakt shows."""
if self.recommended_list not in (
Expand Down Expand Up @@ -213,6 +230,8 @@ def run(self):
# Update recommended shows from trakt, imdb and anidb
# recommended shows are dogpilled into cache/recommended.dbm

self._purge_after_days()

log.info(u'Started caching recommended shows')

self._get_trakt_shows()
Expand Down
8 changes: 6 additions & 2 deletions medusa/helpers/trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging

from medusa.helpers import get_title_without_year
from medusa.indexers.imdb.api import ImdbIdentifier
from medusa.logger.adapters.style import BraceAdapter

from requests.exceptions import RequestException
Expand Down Expand Up @@ -70,8 +71,11 @@ def create_show_structure(show_obj):
'ids': {}
}
for valid_trakt_id in ['tvdb_id', 'trakt_id', 'tmdb_id', 'imdb_id']:
if show_obj.externals.get(valid_trakt_id):
show['ids'][valid_trakt_id[:-3]] = show_obj.externals.get(valid_trakt_id)
external = show_obj.externals.get(valid_trakt_id)
if external:
if valid_trakt_id == 'imdb_id':
external = ImdbIdentifier(external).imdb_id
show['ids'][valid_trakt_id[:-3]] = external
return show


Expand Down
9 changes: 6 additions & 3 deletions medusa/indexers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ def indexer(self, *args, **kwargs):
def config(self):
if self.indexer_id:
return indexerConfig[self.indexer_id]
# Sort and put the default language first
init_config['valid_languages'].sort(key=lambda i: '\0' if i == app.INDEXER_DEFAULT_LANGUAGE else i)
return init_config
_ = init_config
if app.INDEXER_DEFAULT_LANGUAGE in _:
del _[_['valid_languages'].index(app.INDEXER_DEFAULT_LANGUAGE)]
_['valid_languages'].sort()
_['valid_languages'].insert(0, app.INDEXER_DEFAULT_LANGUAGE)
return _

@property
def name(self):
Expand Down
Loading

0 comments on commit 5de42f0

Please sign in to comment.