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

Vueify snatch-selection #7345

Merged
merged 90 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
c304797
Add history apiv2 handler.
p0psicles Nov 13, 2019
5b64dec
Fix pagination for all history items.
p0psicles Nov 13, 2019
d8a5247
Added store for history [WIP]
p0psicles Nov 16, 2019
e55135f
Add history.js
p0psicles Nov 16, 2019
58c3408
Use a data_generator for the history pagination.
p0psicles Nov 18, 2019
fc6258a
Add show-history.vue component.
p0psicles Nov 18, 2019
146370a
Add apiv2 providers endpoint.
p0psicles Nov 19, 2019
238ad28
Add results path_param.
p0psicles Nov 19, 2019
c18df49
Merge remote-tracking branch 'remotes/origin/develop' into feature/vu…
p0psicles May 26, 2020
63e2015
Added snatch-selection.vue
p0psicles May 26, 2020
5e9deea
Merge remote-tracking branch 'remotes/origin/develop' into feature/vu…
p0psicles May 26, 2020
9c63fb8
yarn dev
p0psicles May 26, 2020
7232e90
Store last loaded show in recentShows.
p0psicles May 26, 2020
8cd074a
Add the visited show to the start.
p0psicles May 27, 2020
879835f
Fix getting history for episode when switching between episodes / shows.
p0psicles May 27, 2020
2abdd4a
Added sending a SearchResult through webSockets to the client.
p0psicles May 30, 2020
db407df
Added new component to dislay show results. (used by snatch-selection…
p0psicles May 30, 2020
692aa74
Added store and actions for provider.js.
p0psicles May 30, 2020
f4836d4
Updated snatch-selection.vue with components for history and results.
p0psicles May 30, 2020
5454141
Make sure I get the correct season/episode.
p0psicles May 30, 2020
073ec5d
Merge objects, but do not overwrite the dateAdded field.
p0psicles May 30, 2020
eca302e
Added date searched / time field.
p0psicles May 31, 2020
1eb22cd
Add webSocket support to the queueItems.
p0psicles Jun 1, 2020
b49cf0a
Refactored config related stores.
p0psicles Jun 1, 2020
a97fb60
use queueItems to update manual search messages.
p0psicles Jun 4, 2020
576bc31
Standardize the date format across apiv2 and websocket.
p0psicles Jun 5, 2020
5f66f4c
Add other vgt fields to show-results.vue
p0psicles Jun 5, 2020
bc59428
Merge remote-tracking branch 'remotes/origin/develop' into feature/vu…
p0psicles Jun 5, 2020
f36171f
Added some js string templating.
p0psicles Jun 7, 2020
490b76a
Added quality to history result.
p0psicles Jun 7, 2020
60ad8ba
Fixed api's for history route.
p0psicles Jun 7, 2020
9583d51
Changed identifier for the pickManualSearch function from rowid to id…
p0psicles Jun 7, 2020
3b978c6
Fixed bug in parsing the pubdate for a SearchResult objectd, when cal…
p0psicles Jun 7, 2020
d6311ec
This one's also a rowid -> identifier change
p0psicles Jun 7, 2020
68949e4
set current tab (when chaning tabs in home) should not send apiv2 req…
p0psicles Jun 7, 2020
14c4380
show-history.vue: finished component
p0psicles Jun 7, 2020
8eda20c
show-results.vue: finished component
p0psicles Jun 7, 2020
f29ba89
Fixed vue-good-table styling
p0psicles Jun 7, 2020
402f170
Also the setCurrentTab fix.
p0psicles Jun 7, 2020
f95aef1
updated history.js and provider.js stores.
p0psicles Jun 7, 2020
8d8319f
runtime bundles
p0psicles Jun 7, 2020
abe78b1
Add show to store, when added in backend.
p0psicles Jun 7, 2020
1ae6c95
Remove comments.
p0psicles Jun 7, 2020
35c8a14
whoops
p0psicles Jun 7, 2020
a94c115
Return descriptive fields for the "resouce" field.
p0psicles Jun 15, 2020
da3af43
Fix showing provider/release group in same column.
p0psicles Jun 17, 2020
188be38
Force search, when no initial results found.
p0psicles Jun 17, 2020
4a7358e
Fix searching when no cache present.
p0psicles Jun 17, 2020
788e143
Add episode title to snatchSelection (showHeader) component.
p0psicles Jun 20, 2020
820754c
Add row style to subtitled history item.
p0psicles Jun 21, 2020
029fe4e
Improve history table for subtitle rows
p0psicles Jun 21, 2020
89b9897
Fix displaying xem icon in showHeader.
p0psicles Jun 22, 2020
f7f393c
Add column filters to show-history.vue and show-results.vue tables.
p0psicles Jun 22, 2020
99ab060
Fix show-results.vue release name coloring.
p0psicles Jun 22, 2020
30c59fd
Add season pack support
p0psicles Jun 23, 2020
5e35134
Fix switching between season and episode.
p0psicles Jun 23, 2020
6d9f25d
Fix date parse errors
p0psicles Jun 27, 2020
5e172ed
Fix episode title showing for season pack search
p0psicles Jun 27, 2020
664bbd2
Better 404 error handling
p0psicles Jun 27, 2020
626b2de
Fix double style attribute in history.mako
p0psicles Jun 27, 2020
4c18bc5
Fix provider icons for failed.
p0psicles Jun 27, 2020
1011a4f
Save show-results sorting in cookie.
p0psicles Jun 28, 2020
d3a5456
Add onError fallback provider image
p0psicles Jun 28, 2020
0ca2979
Refactor store /config -> /config/general
p0psicles Jul 5, 2020
5a4c587
Fixed manage_backlogOverview.mako style for allowed.
p0psicles Jul 5, 2020
4d41b2a
Fix manage/mass-update
p0psicles Jul 5, 2020
b7e23dc
Fixed show-results.
p0psicles Jul 5, 2020
5373154
Also fix the date console errors, for when new results come in throug…
p0psicles Jul 5, 2020
1ddc974
Improve storing cookies for vue-good-table sorting.
p0psicles Jul 5, 2020
f9a26a6
Use provider image, with provider name (tooltip) for show-history.vue…
p0psicles Jul 5, 2020
13b7473
Fix clear warnings in sub-menus.js.
p0psicles Jul 10, 2020
ce9653c
Fixed home.vue smallposter and banner styling.
p0psicles Jul 11, 2020
76f4c68
Fix app-link.spec.js test.
p0psicles Jul 11, 2020
1256765
Fix save/loading home.vue layout by cookie.
p0psicles Jul 11, 2020
382b9d2
Refactor state.config -> state.config.general
p0psicles Jul 11, 2020
d072b09
Fixed tests
p0psicles Jul 11, 2020
6fcc6f2
Enable series asset (poster, banner, fanart) cache-control.
p0psicles Jul 11, 2020
636ad81
Wrote my "own" lazy-image component.
p0psicles Jul 12, 2020
4cfe585
Fixed typo
p0psicles Jul 12, 2020
acaa153
my system trippin
p0psicles Jul 12, 2020
61779fb
Fixed lazy-load component.
p0psicles Jul 12, 2020
cbe03c7
Improve speed switching layouts.
p0psicles Jul 12, 2020
17b652d
Fix duplicate class error.
p0psicles Jul 12, 2020
8c6f0d7
Add jest tests for show-history and show-results
p0psicles Jul 16, 2020
126a2c0
Fix lint errors
p0psicles Jul 16, 2020
406e2af
Status donwloaded should not display a provider icon.
p0psicles Jul 16, 2020
c900fc9
Fix flake warnings.
p0psicles Jul 16, 2020
a0d5f54
Last of the flake warnings
p0psicles Jul 16, 2020
dcef691
Fix show-history.spec.js
p0psicles Jul 16, 2020
e3549d3
rebundle
p0psicles Jul 16, 2020
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
37 changes: 34 additions & 3 deletions medusa/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from dateutil import parser

from medusa import app
from medusa import app, ws
from medusa.common import (
MULTI_EP_RESULT,
Quality,
Expand All @@ -32,7 +32,6 @@
from medusa.logger.adapters.style import BraceAdapter
from medusa.search import SearchType


from six import itervalues

log = BraceAdapter(logging.getLogger(__name__))
Expand Down Expand Up @@ -204,6 +203,34 @@ def __repr__(self):

return '<{0}: {1}>'.format(type(self).__name__, result)

def to_json(self):
"""Return JSON representation."""
return {
'identifier': self.identifier,
'release': self.name,
'season': self.actual_season,
'episodes': self.actual_episodes,
'seasonPack': len(self.actual_episodes) == 0,
'indexer': self.series.indexer,
'seriesId': self.series.series_id,
'showSlug': self.series.identifier.slug,
'url': self.url,
'time': datetime.now().replace(microsecond=0).isoformat(),
'quality': self.quality,
'releaseGroup': self.release_group,
'dateAdded': datetime.now().replace(microsecond=0).isoformat(),
'version': self.version,
'seeders': self.seeders,
'size': self.size,
'leechers': self.leechers,
'pubdate': self.pubdate.replace(microsecond=0).isoformat() if self.pubdate else None,
'provider': {
'id': self.provider.get_id(),
'name': self.provider.name,
'imageName': self.provider.image_name()
}
}

def file_name(self):
return u'{0}.{1}'.format(self.episodes[0].pretty_name(), self.result_type)

Expand All @@ -213,6 +240,10 @@ def add_result_to_cache(self, cache):
# FIXME: Added repr parsing, as that prevents the logger from throwing an exception.
# This can happen when there are unicode decoded chars in the release name.
log.debug('Adding item from search to cache: {release_name!r}', release_name=self.name)

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

return cache.add_cache_entry(self, parsed_result=self.parsed_result)

def _create_episode_objects(self):
Expand Down Expand Up @@ -279,7 +310,7 @@ def update_from_db(self):
self.leechers = int(cached_result['leechers'])
self.release_group = cached_result['release_group']
self.version = int(cached_result['version'])
self.pubdate = cached_result['pubdate']
self.pubdate = parser.parse(cached_result['pubdate']) if cached_result['pubdate'] else None
self.proper_tags = cached_result['proper_tags'].split('|') \
if cached_result['proper_tags'] else []
self.date = datetime.today()
Expand Down
29 changes: 25 additions & 4 deletions medusa/generic_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

from __future__ import unicode_literals

import datetime
import logging
import threading
from builtins import object
from datetime import datetime
from functools import cmp_to_key
from uuid import uuid4


log = logging.getLogger()

Expand Down Expand Up @@ -46,7 +48,7 @@ def add_item(self, item):
:return: item
"""
with self.lock:
item.added = datetime.datetime.now()
item.added = datetime.utcnow()
self.queue.append(item)

return item
Expand Down Expand Up @@ -111,19 +113,38 @@ def __init__(self, name, action_id=0):
self.action_id = action_id
self.stop = threading.Event()
self.added = None
self.queue_time = datetime.datetime.now()
self.queue_time = datetime.utcnow()
self.start_time = None
self._to_json = {
'identifier': str(uuid4()),
'name': self.name,
'priority': self.priority,
'actionId': self.action_id,
'queueTime': str(self.queue_time),
'success': None
}

def run(self):
"""Implementing classes should call this."""
self.inProgress = True
self.start_time = datetime.datetime.now()
self.start_time = datetime.utcnow()

def finish(self):
"""Implementing Classes should call this."""
self.inProgress = False
threading.currentThread().name = self.name

@property
def to_json(self):
"""Update queue item JSON representation."""
self._to_json.update({
'inProgress': self.inProgress,
'startTime': str(self.start_time) if self.start_time else None,
'updateTime': str(datetime.utcnow()),
'success': self.success
})
return self._to_json


def fifo(my_list, item, max_size=100):
"""Append item to queue and limit it to 100 items."""
Expand Down
1 change: 1 addition & 0 deletions medusa/indexers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def create_config_json(indexer):


def get_indexer_config():
"""Create a per indexer and main indexer config, used by the apiv2."""
indexers = {
indexerConfig[indexer]['identifier']: create_config_json(indexerConfig[indexer]) for indexer in indexerConfig
}
Expand Down
46 changes: 46 additions & 0 deletions medusa/providers/generic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,3 +848,49 @@ def __str__(self):
def __unicode__(self):
"""Return provider name and provider type."""
return '{provider_name} ({provider_type})'.format(provider_name=self.name, provider_type=self.provider_type)

def to_json(self):
"""Return a json representation for a provider."""
from medusa.providers.torrent.torrent_provider import TorrentProvider
return {
'name': self.name,
'id': self.get_id(),
'config': {
'enabled': self.enabled,
'search': {
'backlog': {
'enabled': self.enable_backlog
},
'manual': {
'enabled': self.enable_backlog
},
'daily': {
'enabled': self.enable_backlog,
'maxRecentItems': self.max_recent_items,
'stopAt': self.stop_at
},
'fallback': self.search_fallback,
'mode': self.search_mode,
'separator': self.search_separator,
'seasonTemplates': self.season_templates,
'delay': {
'enabled': self.enable_search_delay,
'duration': self.search_delay
}
}
},
'animeOnly': self.anime_only,
'type': self.provider_type,
'public': self.public,
'btCacheUrls': self.bt_cache_urls if isinstance(self, TorrentProvider) else [],
'properStrings': self.proper_strings,
'headers': self.headers,
'supportsAbsoluteNumbering': self.supports_absolute_numbering,
'supportsBacklog': self.supports_backlog,
'url': self.url,
'urls': self.urls,
'cookies': {
'enabled': self.enable_cookies,
'required': self.cookies
}
}
69 changes: 68 additions & 1 deletion medusa/search/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import time
import traceback

from medusa import app, common, failed_history, generic_queue, history, ui
from medusa import app, common, failed_history, generic_queue, history, ui, ws
from medusa.helpers import pretty_file_size
from medusa.logger.adapters.style import BraceAdapter
from medusa.search import BACKLOG_SEARCH, DAILY_SEARCH, FAILED_SEARCH, MANUAL_SEARCH, SNATCH_RESULT, SearchType
Expand Down Expand Up @@ -256,13 +256,22 @@ def __init__(self, scheduler_start_time, force):
self.scheduler_start_time = scheduler_start_time
self.force = force

self.to_json.update({
'success': self.success,
'force': self.force
})

def run(self):
"""Run daily search thread."""
generic_queue.QueueItem.run(self)
self.started = True

try:
log.info('Beginning daily search for new episodes')

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

found_results = search_for_needed_episodes(self.scheduler_start_time, force=self.force)

if not found_results:
Expand Down Expand Up @@ -315,6 +324,9 @@ def run(self):
if self.success is None:
self.success = False

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

self.finish()


Expand Down Expand Up @@ -345,6 +357,13 @@ def __init__(self, show, segment, manual_search_type='episode'):
self.segment = segment
self.manual_search_type = manual_search_type

self.to_json.update({
'show': self.show.to_json(),
'segment': [ep.to_json() for ep in self.segment],
'success': self.success,
'manualSearchType': self.manual_search_type
})

def run(self):
"""Run manual search thread."""
generic_queue.QueueItem.run(self)
Expand All @@ -359,6 +378,9 @@ def run(self):
}
)

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

search_result = search_providers(self.show, self.segment, forced_search=True, down_cur_quality=True,
manual_search=True, manual_search_type=self.manual_search_type)

Expand Down Expand Up @@ -396,6 +418,10 @@ def run(self):
if self.success is None:
self.success = False

# Push an update to any open Web UIs through the WebSocket
msg = ws.Message('QueueItemUpdate', self.to_json)
msg.push()

self.finish()


Expand Down Expand Up @@ -423,6 +449,13 @@ def __init__(self, show, segment, search_result):
self.results = None
self.search_result = search_result

self.to_json.update({
'show': self.show.to_json(),
'segment': [ep.to_json() for ep in self.segment],
'success': self.success,
'searchResult': self.search_result.to_json()
})

def run(self):
"""Run manual snatch job."""
generic_queue.QueueItem.run(self)
Expand All @@ -434,6 +467,10 @@ def run(self):
log.info('Beginning to snatch release: {name}',
{'name': result.name})

# Push an update to any open Web UIs through the WebSocket
msg = ws.Message('QueueItemUpdate', self.to_json)
msg.push()

if result:
if result.seeders not in (-1, None) and result.leechers not in (-1, None):
log.info(
Expand Down Expand Up @@ -473,6 +510,10 @@ def run(self):
if self.success is None:
self.success = False

# Push an update to any open Web UIs through the WebSocket
msg = ws.Message('QueueItemUpdate', self.to_json)
msg.push()

self.finish()


Expand All @@ -491,6 +532,12 @@ def __init__(self, show, segment):
self.show = show
self.segment = segment

self.to_json.update({
'show': self.show.to_json(),
'segment': [ep.to_json() for ep in self.segment],
'success': self.success
})

def run(self):
"""Run backlog search thread."""
generic_queue.QueueItem.run(self)
Expand All @@ -500,6 +547,10 @@ def run(self):
try:
log.info('Beginning backlog search for: {name}',
{'name': self.show.name})

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

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

if search_result:
Expand Down Expand Up @@ -557,6 +608,9 @@ def run(self):
if self.success is None:
self.success = False

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

self.finish()


Expand All @@ -576,11 +630,21 @@ def __init__(self, show, segment, down_cur_quality=False):
self.segment = segment
self.down_cur_quality = down_cur_quality

self.to_json.update({
'show': self.show.to_json(),
'segment': [ep.to_json() for ep in self.segment],
'success': self.success,
'downloadCurrentQuality': self.down_cur_quality
})

def run(self):
"""Run failed thread."""
generic_queue.QueueItem.run(self)
self.started = True

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

try:
for ep_obj in self.segment:

Expand Down Expand Up @@ -657,6 +721,9 @@ def run(self):
if self.success is None:
self.success = False

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

self.finish()


Expand Down
Loading