Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/post-processing-sync-files
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkykh committed Sep 9, 2018
2 parents 562e51c + b2dbc4d commit e951e89
Show file tree
Hide file tree
Showing 21 changed files with 126 additions and 39 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@

#### Fixes
- Fixed many release name parsing issues as a result of updating `guessit` ([#4244](https://github.com/pymedusa/Medusa/pull/4244))
- Fixed UI bugs in home page (when using "split home in tabs") and status page ([#5126](https://github.com/pymedusa/Medusa/pull/5126) + [#5127](https://github.com/pymedusa/Medusa/pull/5127))
- Fixed Post Processing config saving `select-list` values incorrectly ([#5165](https://github.com/pymedusa/Medusa/pull/5165))
- Fixed error due to `null` values in the episodes database table ([#5132](https://github.com/pymedusa/Medusa/pull/5132))
- Fixed extraneous calls to AniDB when navigating to any show's page ([#5166](https://github.com/pymedusa/Medusa/pull/5166))
- Fixed being unable to start Medusa due to an import error ([#5145](https://github.com/pymedusa/Medusa/pull/5145))
- Fixed UI bugs on:
- Home page (when using "split home in tabs") ([#5126](https://github.com/pymedusa/Medusa/pull/5126))
- Status page ([#5127](https://github.com/pymedusa/Medusa/pull/5127))
- Preview Rename page ([#5169](https://github.com/pymedusa/Medusa/pull/5169))
- Post Processing Config page - saving `select-list` values incorrectly ([#5165](https://github.com/pymedusa/Medusa/pull/5165))

-----

Expand Down
7 changes: 7 additions & 0 deletions dredd/api-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ paths:
description: Filter series based on paused status
type: boolean
- $ref: '#/parameters/detailed'
- $ref: '#/parameters/fetch'
- $ref: '#/parameters/page'
- $ref: '#/parameters/limit'
- $ref: '#/parameters/sort'
Expand Down Expand Up @@ -1829,6 +1830,12 @@ parameters:
required: false
description: Whether response should contain detailed information
type: boolean
fetch:
name: fetch
in: query
required: false
description: Whether response should fetch external information
type: boolean
page:
name: page
in: query
Expand Down
2 changes: 0 additions & 2 deletions ext/backports/__init__.py

This file was deleted.

1 change: 1 addition & 0 deletions ext/configparser.pth
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('backports',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('backports', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('backports', [os.path.dirname(p)])));m = m or sys.modules.setdefault('backports', types.ModuleType('backports'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p)
2 changes: 1 addition & 1 deletion ext/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:: | `chardet` | [3.0.4](https://pypi.org/project/chardet/3.0.4/) | **`medusa`**, `beautifulsoup4`, `feedparser`, `html5lib`, `pysrt`, `requests`, `subliminal` | -
:: | `cloudflare-scrape` | pymedusa/[320456e](https://github.com/pymedusa/cloudflare-scrape/tree/320456e8b28cedb807363a7a892b1379db843f66) | **`medusa`** | Module: `cfscrape`
:: | <code><b>configobj</b>.py</code><br>`validate.py`<br>`_version.py` | [5.0.6](https://pypi.org/project/configobj/5.0.6/) | **`medusa`** | -
:: | <code><b>configparser</b>.py</code><br>`backports.configparser` | [3.5.0](https://pypi.org/project/configparser/3.5.0/) | `adba` | -
:: | <code><b>configparser</b>.py</code><br>`configparser.pth`<br>`backports.configparser` | [3.5.0](https://pypi.org/project/configparser/3.5.0/) | `adba` | `configparser.pth` was renamed from `configparser-3.5.0-py2.7-nspkg.pth`
:: | <code><b>contextlib2</b>.py</code> | [0.5.5](https://pypi.org/project/contextlib2/0.5.5/) | **`medusa`**, `tvdbapiv2`, `vcrpy`(?) | Markers: `python_version < '3.5'`
:: | <code><b>decorator</b>.py</code> | [4.3.0](https://pypi.org/project/decorator/4.3.0/) | `validators` | -
:: | `dirtyjson` | [1.0.7](https://pypi.org/project/dirtyjson/1.0.7/) | **`medusa`** | -
Expand Down
36 changes: 34 additions & 2 deletions medusa/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import mimetypes
import os
import shutil
import site
import sys


Expand Down Expand Up @@ -46,8 +47,39 @@ def _ext_lib_location():


def _configure_syspath():
sys.path.insert(1, _lib_location())
sys.path.insert(1, _ext_lib_location())
"""Add the vendored libraries into `sys.path`."""
# Note: These paths will be inserted into `sys.path` in reverse order (LIFO)
# So the last path on this list will be inserted as the first path on `sys.path`
# right after the current working dir.
# For example: [ cwd, pathN, ..., path1, path0, <rest_of_sys.path> ]

paths_to_insert = [
_lib_location(),
_ext_lib_location()
]

if sys.version_info[0] == 2:
# Add Python 2-only vendored libraries
paths_to_insert.extend([
# path_to_lib2,
# path_to_ext2
])
elif sys.version_info[0] == 3:
# Add Python 3-only vendored libraries
paths_to_insert.extend([
# path_to_lib3,
# path_to_ext3
])

# Insert paths into `sys.path` and handle `.pth` files
# Inspired by: https://bugs.python.org/issue7744
for dirpath in paths_to_insert:
# Clear `sys.path`
sys.path, remainder = sys.path[:1], sys.path[1:]
# Add directory as a site-packages directory and handle `.pth` files
site.addsitedir(dirpath)
# Restore rest of `sys.path`
sys.path.extend(remainder)


def _register_utf8_codec():
Expand Down
3 changes: 1 addition & 2 deletions medusa/server/api/v2/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def http_get(self, resource, path_param=None):
{'func': resource_function_name, 'resource': resource})
return self._bad_request('{key} is a invalid resource'.format(key=resource))

data = resource_function()
return self._ok(data=data)
return resource_function()

# existingSeries
def resource_existing_series(self):
Expand Down
9 changes: 7 additions & 2 deletions medusa/server/api/v2/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def filter_series(current):

if not series_slug:
detailed = self._parse_boolean(self.get_argument('detailed', default=False))
data = [s.to_json(detailed=detailed) for s in Series.find_series(predicate=filter_series)]
fetch = self._parse_boolean(self.get_argument('fetch', default=False))
data = [
s.to_json(detailed=detailed, fetch=fetch)
for s in Series.find_series(predicate=filter_series)
]
return self._paginate(data, sort='title')

identifier = SeriesIdentifier.from_slug(series_slug)
Expand All @@ -61,7 +65,8 @@ def filter_series(current):
return self._not_found('Series not found')

detailed = self._parse_boolean(self.get_argument('detailed', default=True))
data = series.to_json(detailed=detailed)
fetch = self._parse_boolean(self.get_argument('fetch', default=False))
data = series.to_json(detailed=detailed, fetch=fetch)
if path_param:
if path_param not in data:
return self._bad_request("Invalid path parameter '{0}'".format(path_param))
Expand Down
2 changes: 1 addition & 1 deletion medusa/tv/episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def load_from_db(self, season, episode):
self.airdate = date.fromordinal(int(sql_results[0]['airdate']))
self.status = int(sql_results[0]['status'] or UNSET)
self.quality = int(sql_results[0]['quality'] or Quality.NA)
self.watched = int(sql_results[0]['watched'])
self.watched = bool(sql_results[0]['watched'])

# don't overwrite my location
if sql_results[0]['location']:
Expand Down
38 changes: 24 additions & 14 deletions medusa/tv/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -1965,8 +1965,13 @@ def __unicode__(self):
to_return += u'anime: {0}\n'.format(self.is_anime)
return to_return

def to_json(self, detailed=True):
"""Return JSON representation."""
def to_json(self, detailed=True, fetch=False):
"""
Return JSON representation.
:param detailed: Append seasons & episodes data as well
:param fetch: Fetch and append external data (for example AniDB release groups)
"""
bw_list = self.release_groups or BlackAndWhiteList(self)

data = {}
Expand Down Expand Up @@ -2018,22 +2023,27 @@ def to_json(self, detailed=True):
data['config']['defaultEpisodeStatus'] = self.default_ep_status_name
data['config']['aliases'] = list(self.aliases)
data['config']['release'] = {}
# These are for now considered anime-only options, as they query anidb for available release groups.
data['config']['release']['ignoredWords'] = self.release_ignore_words
data['config']['release']['requiredWords'] = self.release_required_words

# These are for now considered anime-only options
if self.is_anime:
data['config']['release']['blacklist'] = bw_list.blacklist
data['config']['release']['whitelist'] = bw_list.whitelist
try:
data['config']['release']['allgroups'] = get_release_groups_for_anime(self.name)
except AnidbAdbaConnectionException as error:
data['config']['release']['allgroups'] = []
log.warning(
'An anidb adba exception occurred when attempting to get the release groups for the show {show}'
'\nError: {error}',
{'show': self.name, 'error': error}
)

data['config']['release']['ignoredWords'] = self.release_ignore_words
data['config']['release']['requiredWords'] = self.release_required_words
# Fetch data from external sources
if fetch:
# These are for now considered anime-only options, as they query anidb for available release groups.
if self.is_anime:
try:
data['config']['release']['allgroups'] = get_release_groups_for_anime(self.name)
except AnidbAdbaConnectionException as error:
data['config']['release']['allgroups'] = []
log.warning(
'An anidb adba exception occurred when attempting to get the release groups for the show {show}'
'\nError: {error}',
{'show': self.name, 'error': error}
)

if detailed:
episodes = self.get_all_episodes()
Expand Down
2 changes: 1 addition & 1 deletion themes-default/slim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@babel/preset-env": "7.0.0",
"@babel/register": "7.0.0",
"@mapbox/stylelint-processor-arbitrary-tags": "0.2.0",
"@vue/test-utils": "1.0.0-beta.24",
"@vue/test-utils": "1.0.0-beta.25",
"ava": "1.0.0-beta.8",
"axios": "0.18.0",
"babel-loader": "8.0.2",
Expand Down
28 changes: 27 additions & 1 deletion themes-default/slim/src/store/modules/shows.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,43 @@ const getters = {
}
};

/**
* An object representing request parameters for getting a show from the API.
*
* @typedef {Object} ShowParameteres
* @property {string} indexer - The indexer name (e.g. `tvdb`)
* @property {string} id - The show ID on the indexer (e.g. `12345`)
* @property {boolean} detailed - Whether to fetch detailed information (seasons & episodes)
* @property {boolean} fetch - Whether to fetch external information (for example AniDB release groups)
*/
const actions = {
getShow(context, { indexer, id, detailed }) {
/**
* Get show from API and commit it to the store.
*
* @param {*} context - The store context.
* @param {ShowParameteres} parameters - Request parameters.
* @returns {Promise} The API response.
*/
getShow(context, { indexer, id, detailed, fetch }) {
const { commit } = context;
const params = {};
if (detailed !== undefined) {
params.detailed = Boolean(detailed);
}
if (fetch !== undefined) {
params.fetch = Boolean(fetch);
}
return api.get('/series/' + indexer + id, { params }).then(res => {
commit(ADD_SHOW, res.data);
});
},
/**
* Get shows from API and commit them to the store.
*
* @param {*} context - The store context.
* @param {ShowParameteres[]} shows - Shows to get. If not provided, gets the first 1000 shows.
* @returns {(undefined|Promise)} undefined if `shows` was provided or the API response if not.
*/
getShows(context, shows) {
const { commit, dispatch } = context;

Expand Down
3 changes: 2 additions & 1 deletion themes-default/slim/views/editShow.mako
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ window.app = new Vue({
created() {
const { $store, seriesSlug } = this;
const params = { detailed: false }; // Don't get episodes
// Don't get episodes, but do get external information for AniDB release groups
const params = { detailed: false, fetch: true };
api.get('series/' + seriesSlug, { params }).then(response => {
this.series = Object.assign({}, this.series, response.data);
this.seriesLoaded = true;
Expand Down
2 changes: 1 addition & 1 deletion themes-default/slim/views/testRename.mako
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ window.app = {};
window.app = new Vue({
store,
router,
el: '#vue-wrap'
el: '#vue-wrap',
mounted() {
$('.seriesCheck').on('click', function() {
const serCheck = this;
Expand Down
6 changes: 3 additions & 3 deletions themes-default/slim/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -708,9 +708,9 @@
source-map "^0.5.6"
vue-template-es2015-compiler "^1.6.0"

"@vue/[email protected].24":
version "1.0.0-beta.24"
resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.24.tgz#da7c3165f49f57f23fdb98caccba0f511effb76f"
"@vue/[email protected].25":
version "1.0.0-beta.25"
resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.25.tgz#4703076de3076bac42cdd242cd53e6fb8752ed8c"
dependencies:
lodash "^4.17.4"

Expand Down
Loading

0 comments on commit e951e89

Please sign in to comment.