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

Feature: add new show lost categories beside series and anime #8308

Merged
merged 18 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## Unreleased

#### New Features
- Added Search shows by id ([#8058](https://github.com/pymedusa/Medusa/pull/8058))
- Added Search shows by id ([#8308](https://github.com/pymedusa/Medusa/pull/8308))
- Added UI option to create your own show list categories ([#8308](https://github.com/pymedusa/Medusa/pull/8308))

#### Improvements
- Vueified Home page (Poster, small poster, banner, simple layouts) ([5345](https://github.com/pymedusa/Medusa/pull/5345))
- Vueified Snatch Selection page ([7345](https://github.com/pymedusa/Medusa/pull/7345))

#### Fixes

Expand Down
3 changes: 2 additions & 1 deletion medusa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,13 +945,13 @@ def initialize(self, console_logging=True):

app.USE_LISTVIEW = bool(check_setting_int(app.CFG, 'General', 'use_listview', 0))

app.ANIMESUPPORT = False
app.USE_ANIDB = bool(check_setting_int(app.CFG, 'ANIDB', 'use_anidb', 0))
app.ANIDB_USERNAME = check_setting_str(app.CFG, 'ANIDB', 'anidb_username', '', censor_log='normal')
app.ANIDB_PASSWORD = check_setting_str(app.CFG, 'ANIDB', 'anidb_password', '', censor_log='low')
app.ANIDB_USE_MYLIST = bool(check_setting_int(app.CFG, 'ANIDB', 'anidb_use_mylist', 0))
app.ANIME_SPLIT_HOME = bool(check_setting_int(app.CFG, 'ANIME', 'anime_split_home', 0))
app.ANIME_SPLIT_HOME_IN_TABS = bool(check_setting_int(app.CFG, 'ANIME', 'anime_split_home_in_tabs', 0))
app.AUTO_ANIME_TO_LIST = bool(check_setting_int(app.CFG, 'ANIME', 'auto_anime_to_list', 0))

app.METADATA_KODI = check_setting_list(app.CFG, 'General', 'metadata_kodi', ['0'] * 10, transform=int)
app.METADATA_KODI_12PLUS = check_setting_list(app.CFG, 'General', 'metadata_kodi_12plus', ['0'] * 10, transform=int)
Expand Down Expand Up @@ -1979,6 +1979,7 @@ def save_config():
new_config['ANIME'] = {}
new_config['ANIME']['anime_split_home'] = int(app.ANIME_SPLIT_HOME)
new_config['ANIME']['anime_split_home_in_tabs'] = int(app.ANIME_SPLIT_HOME_IN_TABS)
new_config['ANIME']['auto_anime_to_list'] = int(app.AUTO_ANIME_TO_LIST)

new_config.write()

Expand Down
2 changes: 1 addition & 1 deletion medusa/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,14 +445,14 @@ def __init__(self):
self.NMJ_DATABASE = None
self.NMJ_MOUNT = None

self.ANIMESUPPORT = False
self.USE_ANIDB = False
self.ANIDB_USERNAME = None
self.ANIDB_PASSWORD = None
self.ANIDB_USE_MYLIST = False
self.ADBA_CONNECTION = None
self.ANIME_SPLIT_HOME = False
self.ANIME_SPLIT_HOME_IN_TABS = False
self.AUTO_ANIME_TO_LIST = False

self.USE_SYNOINDEX = False

Expand Down
23 changes: 23 additions & 0 deletions medusa/databases/main_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,3 +922,26 @@ def execute(self):
)

self.inc_minor_version()


class AddShowLists(MoveSceneExceptions):
"""Add show_lists field to tv_shows."""

def test(self):
"""Test if the version is at least 44.16."""
return self.connection.version >= (44, 16)

def execute(self):
utils.backup_database(self.connection.path, self.connection.version)

log.info(u'Addin show_lists field to tv_shows.')
if not self.hasColumn('tv_shows', 'show_lists'):
self.addColumn('tv_shows', 'show_lists', 'text', 'series')

# Shows that are not flagged as anime, put in the anime list
self.connection.action("update tv_shows set show_lists = 'series' where anime = 0")

# Shows that are flagged as anime, put in the anime list
self.connection.action("update tv_shows set show_lists = 'anime' where anime = 1")

self.inc_minor_version()
16 changes: 0 additions & 16 deletions medusa/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,22 +741,6 @@ def fix_set_group_id(child_path):
{'path': child_path, 'gid': parent_gid})


def is_anime_in_show_list():
"""Check if any shows in list contain anime.

:return: True if global showlist contains Anime, False if not
"""
for show in app.showList:
if show.is_anime:
return True
return False


def update_anime_support():
"""Check if we need to support anime, and if we do, enable the feature."""
app.ANIMESUPPORT = is_anime_in_show_list()


def get_absolute_number_from_season_and_episode(series_obj, season, episode):
"""Find the absolute number for a show episode.

Expand Down
24 changes: 22 additions & 2 deletions medusa/server/api/v2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,6 @@ class ConfigHandler(BaseRequestHandler):
'layout.wide': BooleanField(app, 'LAYOUT_WIDE'),
'layout.posterSortdir': IntegerField(app, 'POSTER_SORTDIR'),
'layout.themeName': StringField(app, 'THEME_NAME', setter=theme_name_setter),
'layout.animeSplitHomeInTabs': BooleanField(app, 'ANIME_SPLIT_HOME'),
'layout.animeSplitHome': BooleanField(app, 'ANIME_SPLIT_HOME'),
'layout.timezoneDisplay': StringField(app, 'TIMEZONE_DISPLAY'),
'layout.trimZero': BooleanField(app, 'TRIM_ZERO'),
'layout.sortArticle': BooleanField(app, 'SORT_ARTICLE'),
Expand All @@ -475,6 +473,15 @@ class ConfigHandler(BaseRequestHandler):
'layout.timeStyle': StringField(app, 'TIME_PRESET_W_SECONDS'),
'layout.dateStyle': StringField(app, 'DATE_PRESET'),
'layout.selectedRootIndex': IntegerField(app, 'SELECTED_ROOT'),

'layout.animeSplitHome': BooleanField(app, 'ANIME_SPLIT_HOME'),
'layout.splitHomeInTabs': BooleanField(app, 'ANIME_SPLIT_HOME_IN_TABS'),

'anime.anidb.enabled': BooleanField(app, 'USE_ANIDB'),
'anime.anidb.username': StringField(app, 'ANIDB_USERNAME'),
'anime.anidb.password': StringField(app, 'ANIDB_PASSWORD'),
'anime.anidb.useMylist': BooleanField(app, 'ANIDB_USE_MYLIST'),
'anime.autoAnimeToList': BooleanField(app, 'AUTO_ANIME_TO_LIST')
}

def get(self, identifier, path_param=None):
Expand Down Expand Up @@ -1202,3 +1209,16 @@ def data_layout():
section_data['selectedRootIndex'] = int_default(app.SELECTED_ROOT, -1) # All paths

return section_data

@staticmethod
def data_anime():
"""Anime configuration."""
return {
'anidb': {
'enabled': bool(app.USE_ANIDB),
'username': app.ANIDB_USERNAME,
'password': app.ANIDB_PASSWORD,
'useMylist': bool(app.ANIDB_USE_MYLIST)
},
'autoAnimeToList': bool(app.AUTO_ANIME_TO_LIST)
}
1 change: 1 addition & 0 deletions medusa/server/api/v2/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def patch(self, series_slug, path_param=None):
'config.qualities.preferred': ListField(series, 'qualities_preferred'),
'config.qualities.combined': IntegerField(series, 'quality'),
'config.airdateOffset': IntegerField(series, 'airdate_offset'),
'config.showLists': ListField(Series, 'show_lists'),
}

for key, value in iter_nested_items(data):
Expand Down
48 changes: 6 additions & 42 deletions medusa/server/web/config/anime.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@

from __future__ import unicode_literals

import os

from medusa import (
app,
config,
logger,
ui,
)
from medusa.server.web.config.handler import Config
from medusa.server.web.core import PageTemplate

Expand All @@ -20,44 +12,16 @@

@route('/config/anime(/?.*)')
class ConfigAnime(Config):
"""
Handler for Anime configuration
"""
"""Handler for Anime configuration."""

def __init__(self, *args, **kwargs):
super(ConfigAnime, self).__init__(*args, **kwargs)

def index(self):
"""
Render the Anime configuration page
"""

t = PageTemplate(rh=self, filename='config_anime.mako')
Render the anime configuration page.

return t.render(controller='config', action='anime')

def saveAnime(self, use_anidb=None, anidb_username=None, anidb_password=None, anidb_use_mylist=None,
split_home=None, split_home_in_tabs=None):
"""
Save anime related settings
[Converted to VueRouter]
"""

results = []

app.USE_ANIDB = config.checkbox_to_value(use_anidb)
app.ANIDB_USERNAME = anidb_username
app.ANIDB_PASSWORD = anidb_password
app.ANIDB_USE_MYLIST = config.checkbox_to_value(anidb_use_mylist)
app.ANIME_SPLIT_HOME = config.checkbox_to_value(split_home)
app.ANIME_SPLIT_HOME_IN_TABS = config.checkbox_to_value(split_home_in_tabs)

app.instance.save_config()

if results:
for x in results:
logger.log(x, logger.ERROR)
ui.notifications.error('Error(s) Saving Configuration',
'<br>\n'.join(results))
else:
ui.notifications.message('Configuration Saved', os.path.join(app.CONFIG_FILE))

return self.redirect('/config/anime/')
t = PageTemplate(rh=self, filename='index.mako')
return t.render()
15 changes: 13 additions & 2 deletions medusa/tv/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def __init__(self, indexer, indexerid, lang='', quality=None,
self.externals = {}
self._cached_indexer_api = None
self.plot = None
self._show_lists = None

other_show = Show.find_by_id(app.showList, self.indexer, self.series_id)
if other_show is not None:
Expand Down Expand Up @@ -1494,6 +1495,8 @@ def _load_from_db(self):
# Load external id's from indexer_mappings table.
self.externals = load_externals_from_db(self.indexer, self.series_id)

self._show_lists = sql_results[0]['show_lists']

# Get IMDb_info from database
main_db_con = db.DBConnection()
sql_results = main_db_con.select(
Expand Down Expand Up @@ -2023,8 +2026,6 @@ def save_to_db(self):
main_db_con = db.DBConnection()
main_db_con.upsert('tv_shows', new_value_dict, control_value_dict)

helpers.update_anime_support()

if self.imdb_id and self.imdb_info.get('year'):
control_value_dict = {'indexer': self.indexer, 'indexer_id': self.series_id}
new_value_dict = self.imdb_info
Expand Down Expand Up @@ -2158,6 +2159,7 @@ def to_json(self, detailed=False, episodes=False):
data['config']['release']['ignoredWordsExclude'] = bool(self.rls_ignore_exclude)
data['config']['release']['requiredWordsExclude'] = bool(self.rls_require_exclude)
data['config']['airdateOffset'] = self.airdate_offset
data['config']['showLists'] = self.show_lists

# Moved from detailed, as the home page, needs it to display the Xem icon.
data['xemNumbering'] = numbering_tuple_to_dict(self.xem_numbering)
Expand Down Expand Up @@ -2226,6 +2228,15 @@ def qualities_preferred(self, qualities_preferred):
"""Configure qualities (combined) by adding the preferred qualities to it."""
self.quality = Quality.combine_qualities(self.qualities_allowed, qualities_preferred)

@property
def show_lists(self):
"""Return series show lists."""
return self._show_lists.split(',') if self._show_lists else 'series'

@show_lists.setter
def show_lists(self, show_lists):
self._show_lists = ','.join(show_lists) if show_lists else 'series'

def get_all_possible_names(self, season=-1):
"""Get every possible variation of the name for a particular show.

Expand Down
3 changes: 3 additions & 0 deletions themes-default/slim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"jest/**/@babel/core": "7.11.1"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "1.2.30",
"@fortawesome/free-solid-svg-icons": "5.14.0",
"@fortawesome/vue-fontawesome": "0.1.10",
"axios": "0.19.2",
"bootstrap": "3.4.1",
"country-language": "0.1.7",
Expand Down
Loading