Commit 1b9ce09f authored by echel0n's avatar echel0n
Browse files

Refactored add_episodes_to_trakt_watch_list method

Refactored APIBulderHandler get method
Refactored API call CMD_ShowSeasonList
Refactored API call CMD_ShowStats
Fixed issues with API Builder and async calls
Fixed JS issue with schedule view episode details toggle
Bumped jQuery to v3.5.1
Fixed issue with API call for grabbing detailed episode information
parent ee66914f
......@@ -25,7 +25,6 @@ import traceback
import sickrage
from sickrage.core.common import Quality
from sickrage.core.common import SKIPPED, WANTED, UNKNOWN
from sickrage.core.databases.main import MainDB
from sickrage.core.exceptions import EpisodeNotFoundException
from sickrage.core.helpers import sanitize_file_name, make_dir, chmod_as_parent
from sickrage.core.queues.search import BacklogSearchTask
......@@ -99,7 +98,7 @@ class TraktSearcher(object):
def sync_watchlist(self):
sickrage.app.log.debug("Syncing SiCKRAGE with Trakt Watchlist")
self.remove_show_from_sick_rage()
self.remove_show_from_sickrage()
if self._get_show_watchlist():
self.add_show_to_trakt_watch_list()
......@@ -258,19 +257,20 @@ class TraktSearcher(object):
"WATCHLIST::REMOVE::FINISH - Look for Episodes to Remove from Trakt Watchlist")
def add_episodes_to_trakt_watch_list(self):
session = sickrage.app.main_db.session()
trakt_data = []
sickrage.app.log.debug("WATCHLIST::ADD::START - Look for Episodes to Add to Trakt Watchlist")
for s in get_show_list():
for e in session.query(MainDB.TVEpisode).filter_by(showid=s.indexer_id).filter(
~MainDB.TVEpisode.episode.in_(Quality.SNATCHED + Quality.SNATCHED_PROPER + [UNKNOWN] + [WANTED])):
trakt_id = IndexerApi(s.indexer).trakt_id
if self._check_in_list(trakt_id, str(e.showid), e.season, e.episode):
sickrage.app.log.debug("Adding Episode %s S%02dE%02d to watchlist" % (s.name, e.season, e.episode))
trakt_data.append((e.showid, s.indexer, s.name, s.startyear, e.season, e.episode))
for show_object in get_show_list():
for episode_object in show_object.episodes:
if episode_object.status in Quality.SNATCHED + Quality.SNATCHED_PROPER + [UNKNOWN, WANTED]:
continue
trakt_id = IndexerApi(show_object.indexer).trakt_id
if self._check_in_list(trakt_id, str(show_object.indexer_id), episode_object.season, episode_object.episode):
sickrage.app.log.debug("Adding Episode %s S%02dE%02d to watchlist" % (show_object.name, episode_object.season, episode_object.episode))
trakt_data.append(
(show_object.indexer_id, show_object.indexer, show_object.name, show_object.startyear, episode_object.season, episode_object.episode))
if len(trakt_data):
try:
......@@ -309,7 +309,7 @@ class TraktSearcher(object):
sickrage.app.log.debug("SHOW_WATCHLIST::ADD::FINISH - Look for Shows to Add to Trakt Watchlist")
def remove_show_from_sick_rage(self):
def remove_show_from_sickrage(self):
sickrage.app.log.debug("SHOW_SICKRAGE::REMOVE::START - Look for Shows to remove from SiCKRAGE")
for show in get_show_list():
......
This diff is collapsed.
......@@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
import base64
import datetime
import json
import os
......@@ -76,17 +76,17 @@ class APIBulderHandler(BaseHandler, ABC):
def titler(x):
return (remove_article(x), x)[not x or sickrage.app.config.sort_article]
session = sickrage.app.main_db.session()
episodes = {}
for result in session.query(MainDB.TVEpisode).order_by(MainDB.TVEpisode.season, MainDB.TVEpisode.episode):
if result.showid not in episodes:
episodes[result.showid] = {}
if result.season not in episodes[result.showid]:
episodes[result.showid][result.season] = []
for show_object in get_show_list():
if show_object.indexer_id not in episodes:
episodes[show_object.indexer_id] = {}
for episode_object in show_object.episodes:
if episode_object.season not in episodes[show_object.indexer_id]:
episodes[show_object.indexer_id][episode_object.season] = []
episodes[result.showid][result.season].append(result.episode)
episodes[show_object.indexer_id][episode_object.season].append(episode_object.episode)
if len(sickrage.app.config.api_key) == 32:
apikey = sickrage.app.config.api_key
......@@ -101,7 +101,7 @@ class APIBulderHandler(BaseHandler, ABC):
title=_('API Builder'),
header=_('API Builder'),
shows=sorted(get_show_list(), key=cmp_to_key(lambda x, y: titler(x.name) < titler(y.name))),
episodes=episodes,
episodes=base64.b64encode(json.dumps(episodes).encode()).decode(),
apikey=apikey,
api_commands=api_commands,
controller='root',
......
<?xml version="1.0" standalone="no"?>
<!--
Font Awesome Free 5.12.0 by @fontawesome - https://fontawesome.com
Font Awesome Free 5.13.0 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
-->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<metadata>
Created by FontForge 20190801 at Tue Dec 10 16:09:21 2019
Created by FontForge 20190801 at Mon Mar 23 10:45:51 2020
By Robert Madole
Copyright (c) Font Awesome
</metadata>
......@@ -23,7 +23,7 @@ Copyright (c) Font Awesome
bbox="-0.200195 -66.9505 641.5 448.3"
underline-thickness="25"
underline-position="-50"
unicode-range="U+0020-F949"
unicode-range="U+0020-F957"
/>
<missing-glyph />
<glyph glyph-name="twitter-square" unicode="&#xf081;"
......@@ -883,9 +883,14 @@ c9.69922 9.7002 22.8994 15.9004 37.8994 15.9004zM129.4 139.1c0 -21.5996 17.6992
c4 3.5 4 9.7002 -0.100586 13.7002c-3.5 3.5 -9.69922 3.5 -13.1992 0c-29 -29 -121.2 -28.5 -149 0c-3.5 3.5 -9.7002 3.5 -13.2002 0c-4 -4 -4 -10.2002 0 -13.7002c36.3994 -36.3994 139.1 -36.3994 175.5 0zM342.9 99.7998c22 0 39.5996 17.7002 39.6992 39.2002
c0 22.0996 -17.6992 39.7002 -39.6992 39.7002c-21.6006 0 -39.2002 -17.7002 -39.2002 -39.7002c0 -21.5996 17.5996 -39.2002 39.2002 -39.2002z" />
<glyph glyph-name="edge" unicode="&#xf282;" horiz-adv-x="512"
d="M25.7139 219.837c0.111328 0.162109 0.230469 0.323242 0.341797 0.485352c-0.0205078 -0.162109 -0.0449219 -0.323242 -0.0644531 -0.485352h-0.277344zM486.286 204.329l0.000976562 -52.0645h-314.073c1.38379 -128.497 191.392 -124.065 272.255 -67.5713v-104.404
c-47.3555 -28.5244 -156.774 -53.1709 -240.132 -21.3242c-70.6191 27.1406 -119.913 100.528 -120.743 171.977c-1.10742 92.2188 45.6943 153.422 120.742 188.314c-15.7852 -19.9395 -27.9697 -41.54 -34.3389 -78.9258h175.853
c10.2471 104.957 -99.4189 104.957 -99.4189 104.957c-103.302 -3.58984 -177.945 -63.6543 -220.375 -124.966c14.5615 114.465 92.9062 219.955 232.837 219.678c85.0195 0 157.605 -39.8779 198.593 -113.265c21.0469 -37.9404 28.8008 -78.373 28.8008 -122.405z" />
d="M481.92 313.52c6.46973 -12.7793 22.4697 -41.6494 21.9697 -85.0791c-0.0791016 -37.5908 -26.4893 -83.4844 -58.9492 -102.44c-14.957 -8.88379 -41.2148 -16.1318 -58.6104 -16.1797c-0.139648 0 -52.6504 -2.56055 -80.5098 16.8096
c-5.85059 4.08008 -9.14062 8.94043 -9.14062 14c0 6.16016 4.82031 9 6.39062 11c9.7998 12.75 15.1094 28.1699 15.1094 38.5703c0 32.71 -11 59.2998 -33 83.0996c-1.16016 1.25 -42.9795 50.1807 -122.25 50.1807c-63.2393 0 -123.46 -32.6504 -149.46 -79.1406
c24.04 111.98 123.58 195.66 242.44 195.66c96.3496 0 184.96 -46.1797 226.01 -126.48zM212.77 -27.6699c1.28027 -0.570312 29.0107 -20.5898 67.1309 -27.21c-6.53809 -0.628906 -17.1748 -1.13965 -23.7422 -1.13965c-87.0234 0 -187.626 63.9521 -224.559 142.75
c-25.75 55.4697 -24.0801 105.96 -23 118.27c4.16992 34.2803 27.0801 59.7002 46.8408 74.7998c29.6299 22.6904 68.8193 35.6904 107.529 35.6904c7.0498 0 43.9199 -0.900391 77.6406 -18.5898c32.5596 -17.1006 47.3193 -37.5801 56.5596 -53.5107
c1.54688 -2.70312 3.73828 -7.24609 4.88965 -10.1396c-4.21973 4.65039 -40.0596 44.2002 -99.0596 -1c-22.9014 -16.6006 -48.4238 -51.957 -56.9697 -78.9199c-14.1406 -40.4004 -12.8398 -88.5801 20.0996 -136c10.2158 -15.1748 31.1104 -35.334 46.6396 -45z
M463.49 70.6602c1.99316 -1.25879 3.6123 -4.19531 3.6123 -6.55273c0 -1.25195 -0.547852 -3.12305 -1.22266 -4.17773c-47.5703 -75.4297 -127.86 -108.87 -163 -108.87c-22.7002 0 -48.1299 6.95996 -71.7002 19.6104c-33 17.6699 -49.4893 38.7598 -56 47.6699
c-46.3301 63.5303 -28.25 122.29 -13.3301 151.66c8.06445 15.8418 25.4287 38.2422 38.7607 50c-3.50684 -6.9668 -6.42773 -18.9512 -6.52051 -26.75c0 -80.9404 79.8506 -144 171.521 -144h0.341797c19.7266 0 50.7314 5.6084 69.208 12.5195
c5.78809 2.16992 14.9316 6.25586 20.4102 9.12012c0.969727 0.539062 2.65723 0.975586 3.76562 0.975586c1.24316 0 3.10449 -0.540039 4.1543 -1.20508z" />
<glyph glyph-name="codiepie" unicode="&#xf284;" horiz-adv-x="472"
d="M422.5 245.1c30.7002 0 33.5 -53.0996 -0.299805 -53.0996h-10.7998v-44.2998h-26.6006v97.3994h37.7002zM472 95.4004c-42.0996 -91.9004 -121.6 -151.4 -224 -151.4c-137 0 -248 111 -248 248s111 248 248 248c97.4004 0 172.8 -53.7002 218.2 -138.4l-186 -108.8z
M433.5 82.9004l-60.2998 30.6992c-27.1006 -44.2998 -70.4004 -71.3994 -122.4 -71.3994c-82.5 0 -149.2 66.7002 -149.2 148.899c0 82.5 66.7002 149.2 149.2 149.2c48.4004 0 88.9004 -23.5 116.9 -63.3994l59.5 34.5996c-40.7002 62.5996 -104.7 100 -179.2 100
......@@ -3531,5 +3536,35 @@ h-328.399c18.5 25.5 61.6992 54 84.8994 66c35.5 18.0996 76.4004 28.5 105.3 56.299
<glyph glyph-name="unity" unicode="&#xf949;" horiz-adv-x="576"
d="M498.11 241.6l-30 -49.5996l30 -49.6299l-52.8008 -191.62l-197.079 51.3604l-29.2402 50l-59.1699 -0.430664l-144.28 140.32l144.26 140.29l59.2002 -0.429688l29.2002 50.0596l197.109 51.3604zM223.77 323.8l-108.899 -108.13h173.13l86.5498 145.82zM223.77 60.1699
l150.78 -37.6895l-86.5498 145.81h-173.13zM416.77 46.1699l41.79 145.83l-41.8096 145.84l-86.5801 -145.84z" />
<glyph glyph-name="dailymotion" unicode="&#xf952;"
d="M298.93 181c6.01074 -3.36719 13.6152 -10.9834 16.9727 -17c3.36719 -5.95801 6.10059 -16.3477 6.10059 -23.1914c0 -0.0771484 -0.000976562 -0.202148 -0.000976562 -0.27832c-0.0332031 -13.6602 -4.58691 -25.084 -13.6602 -34.2705
s-20.4434 -13.7793 -34.1104 -13.7793c-13.4336 0 -24.5771 4.47949 -33.4307 13.4395s-13.2803 20.4932 -13.2803 34.5996c0 13.4336 4.53711 24.5742 13.6104 33.4209s20.2197 13.2695 33.4395 13.2695c0.174805 0.00195312 0.458984 0.00390625 0.633789 0.00390625
c6.99805 0 17.627 -2.7832 23.7256 -6.21387zM0.00195312 416h448v-448h-448v448zM374.712 42.7402l-0.0302734 264.349l-55.79 -12.0898v-77.9199c-7.81348 7.86035 -16.1465 13.5273 -25 17.001c-7.625 2.88086 -20.4277 5.21777 -28.5791 5.21777
c-0.320312 0 -0.839844 -0.00292969 -1.16016 -0.0078125c-17.6934 -0.00683594 -33.6006 -4.37305 -47.7207 -13.0996c-11.8623 -7.32227 -26.6152 -23.3516 -32.9297 -35.7803c-7.83984 -15.1064 -11.7598 -31.8467 -11.7598 -50.2197
c-0.00683594 -18.8066 3.85645 -35.7705 11.5898 -50.8906c6.26367 -12.4766 21.0205 -28.502 32.9395 -35.7695c14.2197 -8.7334 30.5166 -13.1006 48.8906 -13.1006c26.6602 0 45.2539 8.7334 55.7803 26.2002h0.669922v-23.8896h53.0996z" />
<glyph glyph-name="instagram-square" unicode="&#xf955;"
d="M224 245.34c29.4326 -0.0107422 53.3379 -23.9072 53.3604 -53.3398c0 -29.4434 -23.8965 -53.3398 -53.3408 -53.3398c-29.4434 0 -53.3398 23.8965 -53.3398 53.3398c0 29.4326 23.8877 53.3291 53.3203 53.3398zM348.71 286.34
c8.34961 -21.0703 6.46973 -71.0596 6.46973 -94.3398s1.91992 -73.3301 -6.42969 -94.3301c-4.75 -12.0371 -18.373 -25.6602 -30.4102 -30.4102c-21.0596 -8.35938 -70.9902 -6.42969 -94.2998 -6.42969s-73.3096 -1.86035 -94.3096 6.42969
c-12.0371 4.75 -25.6611 18.373 -30.4102 30.4102c-8.32031 21.0703 -6.4707 71.0605 -6.4707 94.3398c0 23.2803 -1.84961 73.3301 6.43066 94.3301c4.74902 12.0371 18.373 25.6602 30.4102 30.4102c21.0596 8.36035 71.0098 6.42969 94.3096 6.42969
s73.2998 1.86035 94.2998 -6.42969c12.0371 -4.75 25.6602 -18.373 30.4102 -30.4102zM224 110h0.0996094c45.209 0 81.9004 36.6914 81.9004 81.9004v0.0996094c0 45.2637 -36.7363 82 -82 82s-82 -36.7363 -82 -82s36.7363 -82 82 -82zM309.38 258.3
c10.5381 0.00585938 19.1299 8.52246 19.1299 19.0605v0.0800781c0 10.5645 -8.57422 19.1396 -19.1396 19.1396s-19.1396 -8.5752 -19.1396 -19.1396c0 -10.5654 8.57422 -19.1406 19.1396 -19.1406h0.00976562zM400 416c26.4961 0 48 -21.5039 48 -48v-352
c0 -26.4961 -21.5039 -48 -48 -48h-352c-26.4961 0 -48 21.5039 -48 48v352c0 26.4961 21.5039 48 48 48h352zM382.88 126c1.49023 26.4404 1.49023 105.56 0 131.88c-1.21973 25.6299 -7.17969 48.3506 -25.8496 67.0498c-18.6699 18.7002 -41.3701 24.5605 -67 25.8506
c-26.4102 1.48926 -105.59 1.48926 -132 0c-25.5303 -1.2207 -48.2207 -7.12012 -67 -25.7803c-18.7803 -18.6602 -24.5605 -41.3701 -25.8506 -67c-1.48926 -26.3896 -1.48926 -105.58 0 -132c1.2207 -25.5801 7.11035 -48.2998 25.8506 -67
c18.7393 -18.7002 41.3701 -24.5596 67 -25.8496c26.4102 -1.49023 105.59 -1.49023 132 0c25.5996 1.21973 48.29 7.18945 67 25.8496s24.5596 41.3701 25.8496 67z" />
<glyph glyph-name="mixer" unicode="&#xf956;" horiz-adv-x="512"
d="M114.57 371.93l128.319 -172.399c1.27148 -1.75781 2.30371 -4.94531 2.30371 -7.11523s-1.03223 -5.35742 -2.30371 -7.11523l-128.89 -173.24c-7.56738 -10.1514 -23.9863 -18.3916 -36.6484 -18.3916c-9.7998 0 -23.6211 5.36816 -30.8516 11.9824
c-17.8496 16.1797 -18.9697 43.5195 -4.74023 62.7695l92.3301 124.15l-91.7803 123c-14.25 19.25 -12.8291 46.5898 4.75 62.7695c7.23145 6.61719 21.0557 11.9873 30.8574 11.9873c12.665 0 29.0859 -8.24219 36.6533 -18.3975zM470.24 68.4199
c14.2295 -19.25 13.1094 -46.5898 -4.73047 -62.7695c-7.23145 -6.61719 -21.0557 -11.9873 -30.8574 -11.9873c-12.6641 0 -29.085 8.24121 -36.6523 18.3965l-128.57 173.5c-1.27148 1.75879 -2.30273 4.94629 -2.30273 7.11523
c0 2.16992 1.03125 5.35742 2.30273 7.11523l128 172.12c7.56738 10.1553 23.9883 18.3975 36.6533 18.3975c9.80176 0 23.626 -5.37109 30.8574 -11.9873c17.5791 -16.1807 18.9697 -43.5205 4.75 -62.7705l-91.7803 -123z" />
<glyph glyph-name="shopify" unicode="&#xf957;"
d="M388.32 343.9c0.399414 -2.40039 54.4395 -367.9 54.4395 -367.9l-125.689 -31.2002v432.73c8.00977 -8.01074 29.6201 -28.8301 29.6201 -28.8301s35.2295 -0.799805 37.2295 -0.799805c2.12891 -0.0986328 4.10059 -1.89062 4.40039 -4zM288.65 377.53
c9.20996 2.7998 13.6006 4.22461 14.8096 4.39941s3.17969 0.354492 4.40039 0.400391v-438.33l-302.58 52.4805s36.7998 281.819 38 291.819c1.58984 13.2002 2 13.6006 16 18c0.399414 0.400391 19.6094 6.41016 47.2295 14.8105
c2.82031 21.2197 13.21 48.4395 26.8203 70.0596c19.25 30.8301 43.25 48.0303 67.25 48.8301c12.4199 0.370117 22.8203 -3.62988 30.8203 -12.4004c0.399414 -0.799805 1.19922 -1.19922 1.59961 -2c0.947266 0.226562 2.50586 0.40918 3.47949 0.40918
c0.143555 0 0.376953 -0.00390625 0.520508 -0.00878906c18.4199 0 34 -10.8496 44.4404 -30.8604c2.3877 -4.69727 5.61719 -12.5869 7.20996 -17.6094zM233.41 360.31c0.399414 13.21 -1.2002 32.8301 -8.00977 47.2002
c-6.80078 -3.2002 -12.8105 -8.41016 -17.21 -12.8096c-11.21 -12.3701 -20.8203 -31.1807 -25.6201 -50c17.21 5.20996 34.8398 10.8096 50.8398 15.6094zM200.58 423.56c-36.8301 -0.799805 -69.25 -58.8398 -78.0098 -97.2295c13.1699 4 27.5801 8.40039 42 12.8096
c4.7998 24.4502 16.4102 50.0303 31.6201 66.4502c6 6 12.4092 11.21 18.8096 14.4102c-3.48047 1.97266 -9.55273 3.57324 -13.5537 3.57324c-0.239258 0 -0.626953 -0.00585938 -0.866211 -0.0136719zM154.15 203.39c-0.400391 4.81055 0 23.6104 29.6191 25.6201
c20.4209 1.60059 37.6309 -6.39941 37.6309 -6.39941l15.21 57.5996s-13.2305 6.41016 -39.2305 4.80957c-67.25 -4.40918 -97.6699 -51.2393 -94.4697 -97.6797c3.59961 -55.2402 58.8398 -53.2402 60.8398 -86.8594
c0.410156 -8.01074 -4.80957 -19.6201 -18.8096 -20.4209c-21.6201 -1.59961 -48.4404 18.8203 -48.4404 18.8203l-10.4004 -44s26.8203 -28.8203 75.6504 -25.6201c40.4297 2.41016 68.4502 34.8301 65.6504 82.4707c-4 60.4395 -71.6504 66.0498 -73.25 91.6592z
M249.42 365.12c8.80664 2.7998 16.8135 5.2002 24.0205 7.2002c-4.01074 12.4297 -12.8105 32.8301 -31.2305 36.4297c5.61035 -14.4102 7.20996 -31.6299 7.20996 -43.6299z" />
</font>
</defs></svg>
<?xml version="1.0" standalone="no"?>
<!--
Font Awesome Free 5.12.0 by @fontawesome - https://fontawesome.com
Font Awesome Free 5.13.0 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
-->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<metadata>
Created by FontForge 20190801 at Tue Dec 10 16:09:21 2019
Created by FontForge 20190801 at Mon Mar 23 10:45:51 2020
By Robert Madole
Copyright (c) Font Awesome
</metadata>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment