Skip to content

Commit

Permalink
Merge pull request #9114 from pymedusa/release/release-0.5.5
Browse files Browse the repository at this point in the history
Release/release 0.5.5
  • Loading branch information
p0psicles authored Jan 25, 2021
2 parents 2b874c2 + 19dc2ab commit 0b60e12
Show file tree
Hide file tree
Showing 23 changed files with 160 additions and 91 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.5.5 (25-01-2021)

#### Fixes
- Fix auto update causing malformed checkouts ([9088](https://github.com/pymedusa/Medusa/pull/9088))
- Fix trakt recommended shows causing an error when selecting season premiers or new shows ([9080](https://github.com/pymedusa/Medusa/pull/9080))
- Prevent exception when auth to medusa using basic authentication ([9100](https://github.com/pymedusa/Medusa/pull/9100))

-----

## 0.5.4 (20-01-2021)

#### Fixes
Expand Down
4 changes: 2 additions & 2 deletions ext/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ ext | **`subliminal`** | [2.1.0](https://pypi.org/project/subliminal/2.1.0/) | *
ext | **`tmdbsimple`** | [2.7.0](https://pypi.org/project/tmdbsimple/2.7.0/) | **`medusa`** | -
ext | **`tornado`** | [6.1](https://pypi.org/project/tornado/6.1/) | **`medusa`**, `tornroutes` | -
ext | **`tornroutes`** | [0.5.1](https://pypi.org/project/tornroutes/0.5.1/) | **`medusa`** | -
ext | **`trakt`** | [2.14.1](https://pypi.org/project/trakt/2.14.1/) | **`medusa`** | -
ext | **`trakt`** | p0psicles/[8de5bfb](https://github.com/p0psicles/PyTrakt/tree/8de5bfb04b3d5ee54e4a3b25db0e4c341cc31384) | **`medusa`** | -
ext | `trans` | [2.1.0](https://pypi.org/project/trans/2.1.0/) | `imdbpie` | File: `trans.py`
ext | `ttl-cache` | [1.6](https://pypi.org/project/ttl-cache/1.6/) | **`medusa`** | File: `ttl_cache.py`
ext | **`tvdbapiv2`** | pymedusa/[bf1272c](https://github.com/pymedusa/tvdbv2/tree/bf1272c9264c280c3048e89a1920e2bf5f386284) | **`medusa`** | -
ext | **`tvdbapiv2`** | pymedusa/[d6d0e9d](https://github.com/pymedusa/tvdbv2/tree/d6d0e9d98071c2d646beb997b336edbb0e98dfb7) | **`medusa`** | -
ext | **`urllib3`** | [1.24.1](https://pypi.org/project/urllib3/1.24.1/) | `requests` | -
ext | **`validators`** | [0.18.2](https://pypi.org/project/validators/0.18.2/) | **`medusa`** | -
ext | **`webencodings`** | [0.5.1](https://pypi.org/project/webencodings/0.5.1/) | `html5lib` | -
Expand Down
27 changes: 17 additions & 10 deletions ext/trakt/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from pprint import pformat
from trakt.core import get
from trakt.movies import Movie
from trakt.tv import TVEpisode
from trakt.utils import now, airs_date
from trakt.tv import TVEpisode, TVShow
from trakt.utils import extract_ids, now, airs_date

__author__ = 'Jon Nappi'
__all__ = ['Calendar', 'PremiereCalendar', 'MyPremiereCalendar',
Expand Down Expand Up @@ -66,14 +66,21 @@ def _get(self):
def _build(self, data):
"""Build the calendar"""
self._calendar = []
for episode in data:
show = episode.get('show', {}).get('title')
season = episode.get('episode', {}).get('season')
ep = episode.get('episode', {}).get('number')
e_data = {'airs_at': airs_date(episode.get('first_aired')),
'ids': episode.get('episode').get('ids'),
'title': episode.get('episode', {}).get('title')}
self._calendar.append(TVEpisode(show, season, ep, **e_data))
for cal_item in data:
show_data = cal_item.get('show', {})
episode = cal_item.get('episode', {})
first_aired = cal_item.get('first_aired')
season = episode.get('season')
ep_num = episode.get('number')
extract_ids(show_data)
show_data.update(show_data)
e_data = {
'airs_at': airs_date(first_aired),
'ids': episode.get('ids'),
'title': show_data.get('title'),
'show_data': TVShow(**show_data)
}
self._calendar.append(TVEpisode(show_data['trakt'], season, ep_num, **e_data))
self._calendar = sorted(self._calendar, key=lambda x: x.airs_at)


Expand Down
2 changes: 1 addition & 1 deletion ext/trakt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'init', 'BASE_URL', 'CLIENT_ID', 'CLIENT_SECRET', 'DEVICE_AUTH',
'REDIRECT_URI', 'HEADERS', 'CONFIG_PATH', 'OAUTH_TOKEN',
'OAUTH_REFRESH', 'PIN_AUTH', 'OAUTH_AUTH', 'AUTH_METHOD',
'APPLICATION_ID', 'get_device_code', 'get_device_token']
'APPLICATION_ID', 'get_device_code']

#: The base url for the Trakt API. Can be modified to run against different
#: Trakt.tv environments
Expand Down
3 changes: 3 additions & 0 deletions ext/tvdbapiv2/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def request(self, method, url, query_params=None, headers=None, body=None, post_
else:
r = self.session.request(method, url, params=query_params, headers=headers)

if r is None:
raise RequestException('Missing response')

r.raise_for_status()

except RequestException as error:
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.4'
VERSION = '0.5.5'
USER_AGENT = 'Medusa/{version} ({system}; {release}; {instance})'.format(
version=VERSION, system=platform.system(), release=platform.release(),
instance=INSTANCE_ID)
Expand Down
6 changes: 4 additions & 2 deletions medusa/helpers/trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ def get_trakt_show_collection(trakt_list, limit=None):
elif trakt_list == 'recommended':
return tv.recommended_shows(extended='full,images')
elif trakt_list == 'newshow':
return calendar.PremiereCalendar(days=30, extended='full,images', returns='shows')
calendar_items = calendar.PremiereCalendar(days=30, extended='full,images')
return [tv_episode.show_data for tv_episode in calendar_items]
elif trakt_list == 'newseason':
return calendar.SeasonCalendar(days=30, extended='full,images', returns='shows')
calendar_items = calendar.SeasonCalendar(days=15, extended='full,images')
return [tv_episode.show_data for tv_episode in calendar_items]

return tv.anticipated_shows(limit=limit, extended='full,images')
except TraktException as error:
Expand Down
4 changes: 3 additions & 1 deletion medusa/indexers/tvmaze/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ def _get_all_updates(self, start_date=None, end_date=None):
results = []
try:
updates = self.tvmaze_api.show_updates()
except (ShowIndexError, UpdateNotFound):
except (AttributeError, ShowIndexError, UpdateNotFound):
# Tvmaze api depends on .status_code in.., but does not catch request exceptions.
# Therefor the AttributeError.
return results
except BaseError as e:
log.warning('Getting show updates failed. Cause: {0}', e)
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/api/v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _check_authentication(self):
return self._unauthorized('Invalid token.')
elif authorization.startswith('Basic'):
auth_decoded = base64.b64decode(authorization[6:])
username, password = auth_decoded.split(':', 2)
username, password = ensure_text(auth_decoded).split(':', 2)
if username != app.WEB_USERNAME or password != app.WEB_PASSWORD:
return self._unauthorized('Invalid user/pass.')
else:
Expand Down
20 changes: 19 additions & 1 deletion medusa/server/api/v2/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ def post(self, identifier, *args, **kwargs):
ui.notifications.message('Already on branch: ', data['branch'])
return self._bad_request('Already on branch')

if data['type'] == 'NEED_UPDATE':
if self._need_update():
return self._created()
else:
return self._bad_request('Update not needed')

if data['type'] == 'UPDATE':
if self._update():
return self._created()
Expand Down Expand Up @@ -89,12 +95,24 @@ def _backup(self, branch=None):

return False

def _need_update(self, branch=None):
"""Check if we need an update."""
checkversion = CheckVersion()
if branch:
checkversion.updater.branch = branch
if checkversion.updater.need_update():
return True
else:
ui.notifications.message('No updated needed{branch}'.format(
branch=' for branch {0}'.format(branch) if branch else ''
), 'Check logs for more information.')

def _update(self, branch=None):
checkversion = CheckVersion()
if branch:
checkversion.updater.branch = branch

if checkversion.updater.need_update() and checkversion.updater.update():
if checkversion.updater.update():
return True
else:
ui.notifications.message('Update failed{branch}'.format(
Expand Down
6 changes: 3 additions & 3 deletions medusa/server/web/home/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,12 +644,12 @@ def branchCheckout(self, branch):
ui.notifications.message('Already on branch: ', branch)
return self.redirect('/{page}/'.format(page=app.DEFAULT_PAGE))

def branchForceUpdate(self):
@staticmethod
def branchForceUpdate():
return {
'currentBranch': app.BRANCH,
'resetBranches': app.GIT_RESET_BRANCHES,
'branches': [branch for branch in app.version_check_scheduler.action.list_remote_branches()
if branch not in app.GIT_RESET_BRANCHES]
'branches': [branch for branch in app.version_check_scheduler.action.list_remote_branches()]
}

@staticmethod
Expand Down
12 changes: 10 additions & 2 deletions medusa/updater/github_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,18 @@ def update(self):
# Executing git clean before updating
self.clean()

if self.branch == self._find_installed_branch():
current_branch = self._find_installed_branch()
if self.branch == current_branch:
_, _, exit_status = self._run_git(self._git_path, 'pull -f {0} {1}'.format(app.GIT_REMOTE, self.branch))
else:
_, _, exit_status = self._run_git(self._git_path, 'checkout -f ' + self.branch)
log.warning(
u"Couldn't determine current branch or current branch {current}"
u" doesn't match desired branch {desired}.\n"
u'Checkout the desired branch or try again later.', {
'current': current_branch,
'desired': self.branch
})
return False

# Executing git clean after updating
self.clean()
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ subliminal==2.1.0
tmdbsimple==2.7.0
tornado==6.1
tornroutes==0.5.1
trakt==2.14.1
trakt @ https://codeload.github.com/p0psicles/PyTrakt/tar.gz/8de5bfb04b3d5ee54e4a3b25db0e4c341cc31384
ttl-cache==1.6
tvdbapiv2 @ https://codeload.github.com/pymedusa/tvdbv2/tar.gz/bf1272c9264c280c3048e89a1920e2bf5f386284
tvdbapiv2 @ https://codeload.github.com/pymedusa/tvdbv2/tar.gz/d6d0e9d98071c2d646beb997b336edbb0e98dfb7
validators==0.18.2
4 changes: 2 additions & 2 deletions themes-default/slim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jest": "23.20.0",
"eslint-plugin-unicorn": "22.0.0",
"eslint-plugin-vue": "7.4.1",
"eslint-plugin-vue": "7.5.0",
"file-loader": "6.2.0",
"filemanager-webpack-plugin": "3.1.0",
"glob": "7.1.6",
Expand All @@ -110,7 +110,7 @@
"timekeeper": "2.2.0",
"vue-jest": "3.0.7",
"vue-loader": "15.9.6",
"webpack": "5.16.0",
"webpack": "5.17.0",
"webpack-cli": "4.4.0"
},
"stylelint": {
Expand Down
32 changes: 11 additions & 21 deletions themes-default/slim/src/components/config-general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@
<option disabled value="">Please select a branch</option>
<option :value="option.value" v-for="option in githubRemoteBranchesOptions" :key="option.value">{{ option.text }}</option>
</select>
<input :disabled="!githubBranches.length > 0"
<input :disabled="!gitRemoteBranches.length > 0"
class="btn-medusa btn-inline" style="margin-left: 6px;" type="button" id="branchCheckout"
value="Checkout Branch" @click="validateCheckoutBranch"
>
<span v-if="!githubBranches.length > 0" style="color:rgb(255, 0, 0);"><p>Error: No branches found.</p></span>
<span v-if="!gitRemoteBranches.length > 0" style="color:rgb(255, 0, 0);"><p>Error: No branches found.</p></span>
<p v-else>select branch to use (restart required)</p>
<p v-if="checkoutBranchMessage">
<state-switch state="loading" :theme="layout.themeName" />
Expand Down Expand Up @@ -535,9 +535,9 @@
<multiselect
v-model="general.git.resetBranches"
:multiple="true"
:options="githubBranches"
:options="gitRemoteBranches"
/>
<input class="btn-medusa btn-inline" style="margin-left: 6px;" type="button" id="branch_force_update" value="Update Branches" @click="githubBranchForceUpdate">
<input class="btn-medusa btn-inline" style="margin-left: 6px;" type="button" id="branch_force_update" value="Update Branches" @click="gitRemoteBranches()">
<span><b>Note:</b> Empty selection means that any branch could be reset.</span>
</config-template>
<input type="submit" class="btn-medusa config_submitter" value="Save Changes">
Expand Down Expand Up @@ -664,7 +664,6 @@ export default {
return {
defaultPageOptions,
privacyLevelOptions,
githubBranchesForced: [],
resetBranchSelected: null,
saving: false,
selectedBranch: '',
Expand Down Expand Up @@ -758,29 +757,25 @@ export default {
return [];
},
githubRemoteBranchesOptions() {
const { general, githubBranches, githubBranchForceUpdate, gitRemoteBranches } = this;
const { general, getGitRemoteBranches, gitRemoteBranches } = this;
const { username, password, token } = general.git;
if (!gitRemoteBranches.length > 0) {
githubBranchForceUpdate();
getGitRemoteBranches();
}
let filteredBranches = [];
if (((username && password) || token) && general.developer) {
filteredBranches = githubBranches;
filteredBranches = gitRemoteBranches;
} else if ((username && password) || token) {
filteredBranches = githubBranches.filter(branch => ['master', 'develop'].includes(branch));
filteredBranches = gitRemoteBranches.filter(branch => ['master', 'develop'].includes(branch));
} else {
filteredBranches = githubBranches.filter(branch => ['master'].includes(branch));
filteredBranches = gitRemoteBranches.filter(branch => ['master'].includes(branch));
}
return filteredBranches.map(branch => ({ text: branch, value: branch }));
},
githubBranches() {
const { githubBranchesForced, gitRemoteBranches } = this;
return gitRemoteBranches || githubBranchesForced;
},
githubTokenPopover() {
const { general } = this;
return '<p>Copy the generated token and paste it in the token input box.</p>' +
Expand All @@ -793,14 +788,9 @@ export default {
setConfig: 'setConfig',
setTheme: 'setTheme',
getApiKey: 'getApiKey',
setLayoutShow: 'setLayoutShow'
setLayoutShow: 'setLayoutShow',
getGitRemoteBranches: 'getGitRemoteBranches'
}),
async githubBranchForceUpdate() {
const response = await apiRoute('home/branchForceUpdate');
if (response.data._size > 0) {
this.githubBranchesForced = response.data.resetBranches;
}
},
async generateApiKey() {
const { getApiKey, save } = this;
try {
Expand Down
49 changes: 33 additions & 16 deletions themes-default/slim/src/components/update.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
<div id="update">
<template v-if="!startUpdate">
<span>Medusa will automatically create a backup before you update. Are you sure you want to update?</span>
<button id="update-now" class="btn-medusa btn-danger" @click="backup">Yes</button>
<button id="update-now" class="btn-medusa btn-danger" @click="performUpdate">Yes</button>
</template>
<template v-else>
<div id="creating_backup">
<div id="check_update">
Checking if medusa needs an update
<state-switch :theme="layout.themeName" :state="needUpdateStatus" />
</div>
<div v-if="needUpdateStatus === 'yes'" id="creating_backup">
Waiting for Medusa to create a backup:
<state-switch :theme="layout.themeName" :state="backupStatus" />
</div>
Expand Down Expand Up @@ -40,7 +44,8 @@ export default {
return {
startUpdate: false,
backupStatus: 'loading',
updateStatus: 'loading'
updateStatus: 'loading',
needUpdateStatus: 'loading'
};
},
computed: {
Expand All @@ -50,25 +55,37 @@ export default {
})
},
methods: {
async backup() {
/**
* Check if we need an update and start backup / update procedure.
*/
async performUpdate() {
this.startUpdate = true;
try {
await api.post('system/operation', { type: 'BACKUP' }, { timeout: 1200000 });
this.backupStatus = 'yes';
this.update();
await api.post('system/operation', { type: 'NEED_UPDATE' });
this.needUpdateStatus = 'yes';
} catch (error) {
this.backupStatus = 'no';
this.needUpdateStatus = 'no';
}
},
async update() {
try {
await api.post('system/operation', { type: 'UPDATE' });
this.updateStatus = 'yes';
} catch (error) {
this.updateStatus = 'no';
if (this.needUpdateStatus === 'yes') {
try {
await api.post('system/operation', { type: 'BACKUP' }, { timeout: 1200000 });
this.backupStatus = 'yes';
} catch (error) {
this.backupStatus = 'no';
}
}
}
if (this.backupStatus === 'yes') {
try {
await api.post('system/operation', { type: 'UPDATE' });
this.updateStatus = 'yes';
} catch (error) {
this.updateStatus = 'no';
}
}
}
}
};
</script>
Expand Down
Loading

0 comments on commit 0b60e12

Please sign in to comment.