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

Auto change status to Wanted, when starting a forced search for an episode #10796

Merged
merged 3 commits into from
Jul 3, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### Improvements
- Added connection (lost) indicator on the Medusa log ([10774](https://github.com/pymedusa/Medusa/pull/10774))
- Extend subtitle file parsing to allow for titles with language name. ([10782](https://github.com/pymedusa/Medusa/pull/10782))
- Auto change status episode to Wanted, when running a forced search for the episode. [10796](https://github.com/pymedusa/Medusa/pull/10796))

#### Fixes
- Homepage: Fix loading shows from localCache ([10779](https://github.com/pymedusa/Medusa/pull/10779))
Expand Down
4 changes: 4 additions & 0 deletions medusa/search/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
name_cache,
notifiers,
ui,
ws
)
from medusa.clients import torrent
from medusa.clients.nzb import (
Expand Down Expand Up @@ -225,6 +226,9 @@ def snatch_result(result):

sql_l.append(cur_ep_obj.get_sql())

# Push an update with the updated episode to any open Web UIs through the WebSocket
ws.Message('episodeUpdated', cur_ep_obj.to_json()).push()

if cur_ep_obj.status != common.DOWNLOADED:
notifiers.notify_snatch(cur_ep_obj, result)

Expand Down
14 changes: 13 additions & 1 deletion medusa/search/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from builtins import str

from medusa import app, common, db, failed_history, helpers, history, ui, ws
from medusa.common import DOWNLOADED, SNATCHED, SNATCHED_BEST, SNATCHED_PROPER, SUBTITLED
from medusa.common import DOWNLOADED, SNATCHED, SNATCHED_BEST, SNATCHED_PROPER, SUBTITLED, WANTED
from medusa.helper.common import enabled_providers
from medusa.helper.exceptions import AuthException, ex
from medusa.helpers import pretty_file_size
Expand Down Expand Up @@ -569,6 +569,18 @@ def run(self):
# Push an update to any open Web UIs through the WebSocket
ws.Message('QueueItemUpdate', self.to_json).push()

if self.segment:
# Make sure the episodes status has been changed to wanted, before starting the search.
ep_sql_l = []
for episode in self.segment:
ep_sql = episode.mass_update_episode_status(WANTED)
if ep_sql:
ep_sql_l.append(ep_sql)

if ep_sql_l:
main_db_con = db.DBConnection()
main_db_con.mass_action(ep_sql_l)

search_result = search_providers(self.show, self.segment)

if search_result:
Expand Down
7 changes: 7 additions & 0 deletions medusa/tv/episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
notifiers,
post_processor,
subtitles,
ws
)
from medusa.common import (
ARCHIVED,
Expand Down Expand Up @@ -1096,6 +1097,7 @@ def to_json(self, detailed=True):
data['identifier'] = self.identifier
data['id'] = {self.indexer_name: self.indexerid}
data['slug'] = self.slug
data['showSlug'] = self.series.slug
data['season'] = self.season
data['episode'] = self.episode

Expand Down Expand Up @@ -1403,6 +1405,9 @@ def save_to_db(self):
main_db_con = db.DBConnection()
main_db_con.upsert('tv_episodes', new_value_dict, control_value_dict)

# Push an update with the updated episode to any open Web UIs through the WebSocket
ws.Message('episodeUpdated', self.to_json()).push()

self.reset_dirty()

def full_path(self):
Expand Down Expand Up @@ -2199,6 +2204,8 @@ def mass_update_episode_status(self, new_status):
self.manually_searched = False

self.status = new_status
# Push an update with the updated episode to any open Web UIs through the WebSocket
ws.Message('episodeUpdated', self.to_json()).push()

# Make sure to run the collected sql through a mass action.
return self.get_sql()
4 changes: 3 additions & 1 deletion themes-default/slim/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const passToStoreHandler = function(eventName, event, next) {
} else if (event === 'showUpdated' || event === 'showAdded') {
this.store.dispatch('updateShow', data);
} else if (event === 'showRemoved') {
// We need this for the QueueItemChangeIndexer
// We need this for the QueueItemChangeIndexerstatus
this.store.dispatch('removeShow', data);
} else if (event === 'addManualSearchResult') {
this.store.dispatch('addManualSearchResult', data);
Expand All @@ -82,6 +82,8 @@ const passToStoreHandler = function(eventName, event, next) {
}
} else if (event === 'historyUpdate') {
this.store.dispatch('updateHistory', data);
} else if (event === 'episodeUpdated') {
this.store.dispatch('updateEpisode', data);
} else {
window.displayNotification('info', event, data);
}
Expand Down
5 changes: 4 additions & 1 deletion themes-default/slim/src/store/modules/shows.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,11 @@ const actions = {
initShowsFromLocalStorage({ rootState, commit }) {
const namespace = rootState.config.system.webRoot ? `${rootState.config.system.webRoot}_` : '';
return commit('loadShowsFromStore', namespace);
},
updateEpisode({ state, commit }, episode) {
const show = state.shows.find(({ id }) => id.slug === episode.showSlug);
commit(ADD_SHOW_EPISODE, { show, episodes: [episode] });
}

};

export default {
Expand Down
4 changes: 2 additions & 2 deletions themes/dark/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions themes/light/assets/js/medusa-runtime.js

Large diffs are not rendered by default.