Change overhaul and add API functions

Change API version... start with 10
Change set application response header to 'SickGear' + add API version
Change return timezone (of network) in API
Add indexer to calls
Add SickGear Command tip for old SickBeard commands
Add warning old sickbeard API calls only support tvdb shows
Add "tvdbid" fallback only for sickbeard calls
Add listcommands
Add list of all commands (old + new) in listcommand page at the beginning
Change hide 'listcommands' command from commands list, since it needs the API builder CSS + is html not json
Add missing help in webapi
Add episode info: absolute_number, scene_season, scene_episode, scene_absolute_number
Add fork to SB command
Add sg
Add sg.activatescenenumbering
Add sg.addrootdir
Add sg.checkscheduler
Add sg.deleterootdir
Add sg.episode
Add sg.episode.search
Add sg.episode.setstatus
Add sg.episode.subtitlesearch
Add sg.exceptions
Add sg.forcesearch
Add sg.future
Add sg.getdefaults
Add sg.getindexericon
Add sg.getindexers to list all indexers
Add sg.getmessages
Add sg.getnetworkicon
Add sg.getrootdirs
Add sg.getqualities
Add sg.getqualitystrings
Add sg.history
Add sg.history.clear
Add sg.history.trim
Add sg.listtraktaccounts
Add sg.listignorewords
Add sg.listrequiedwords
Add sg.logs
Add sg.pausebacklog
Add sg.postprocess
Add sg.ping
Add sg.restart
Add sg.searchqueue
Add sg.searchtv to search all indexers
Add sg.setexceptions
Add sg.setignorewords
Add sg.setrequiredwords
Add sg.setscenenumber
Add sg.show
Add sg.show.addexisting
Add sg.show.addnew
Add sg.show.cache
Add sg.show.delete
Add sg.show.getbanner
Add sg.show.getfanart
Add sg.show.getposter
Add sg.show.getquality
Add sg.show.listfanart
Add sg.show.ratefanart
Add sg.show.seasonlist
Add sg.show.seasons
Add sg.show.setquality
Add sg.show.stats
Add sg.show.refresh
Add sg.show.pause
Add sg.show.update
Add sg.shows
Add sg.shows.browsetrakt
Add sg.shows.forceupdate
Add sg.shows.queue
Add sg.shows.stats

Change sickbeard to sickgear
Change sickbeard_call to property
Change sg.episode.setstatus allow setting of quality
Change sg.history, history command output
Change sg.searchtv to list of indexers
Add uhd4kweb to qualities
Add upgrade_once to add existing shows
Add upgrade_once to add new show
Add upgrade_once to show quality settings (get/set)
Add 'ids' to Show + Shows
Add ids to coming eps + get tvdb id from ids
Add 'status_str' to coming eps
Add 'local_datetime' to comming eps + runtime
Add X-Filename response header to getbanner, getposter
Add X-Fanartname response header for sg.show.getfanart

Add missing fields to sb.show
Add missing fields to sb.shows
Change sb.seasons
Change overview optional
Change make overview optional in shows
Add setscenenumber to API builder
Change move set_scene_numbering_helper into scnene_numbering for use in web interface and API
Change use quality_map instead of fixed list
Add eigthlevel for API/builder page
Change limit indexer param to valid values
Fix wrong parameter in existing apiBuilder.tmpl that prevents javascript from continuing + add console error message for it
Fixed: filter missed shows correctly
Add @gen.coroutine
This commit is contained in:
Prinz23 2016-08-24 21:02:12 +02:00 committed by JackDandy
parent f7c57d8eb5
commit fe1aabca00
11 changed files with 2712 additions and 531 deletions

View file

@ -1,4 +1,99 @@
### 0.14.0 (2018-02-01 02:30:00 UTC)
### 0.15.0 (2018-xx-xx xx:xx:xx UTC)
* Change overhaul and add API functions
* Change API version... start with 10
* Change set application response header to 'SickGear' + add API version
* Change return timezone (of network) in API
* Add indexer to calls
* Add SickGear Command tip for old SickBeard commands
* Add warning old sickbeard API calls only support tvdb shows
* Add "tvdbid" fallback only for sickbeard calls
* Add listcommands
* Add list of all commands (old + new) in listcommand page at the beginning
* Change hide 'listcommands' command from commands list, since it needs the API builder CSS + is html not json
* Add missing help in webapi
* Add episode info: absolute_number, scene_season, scene_episode, scene_absolute_number
* Add fork to SB command
* Add sg
* Add sg.activatescenenumbering
* Add sg.addrootdir
* Add sg.checkscheduler
* Add sg.deleterootdir
* Add sg.episode
* Add sg.episode.search
* Add sg.episode.setstatus
* Add sg.episode.subtitlesearch
* Add sg.exceptions
* Add sg.forcesearch
* Add sg.future
* Add sg.getdefaults
* Add sg.getindexericon
* Add sg.getindexers to list all indexers
* Add sg.getmessages
* Add sg.getnetworkicon
* Add sg.getrootdirs
* Add sg.getqualities
* Add sg.getqualitystrings
* Add sg.history
* Add sg.history.clear
* Add sg.history.trim
* Add sg.listtraktaccounts
* Add sg.listignorewords
* Add sg.listrequiedwords
* Add sg.logs
* Add sg.pausebacklog
* Add sg.postprocess
* Add sg.ping
* Add sg.restart
* Add sg.searchqueue
* Add sg.searchtv to search all indexers
* Add sg.setexceptions
* Add sg.setignorewords
* Add sg.setrequiredwords
* Add sg.setscenenumber
* Add sg.show
* Add sg.show.addexisting
* Add sg.show.addnew
* Add sg.show.cache
* Add sg.show.delete
* Add sg.show.getbanner
* Add sg.show.getfanart
* Add sg.show.getposter
* Add sg.show.getquality
* Add sg.show.listfanart
* Add sg.show.ratefanart
* Add sg.show.seasonlist
* Add sg.show.seasons
* Add sg.show.setquality
* Add sg.show.stats
* Add sg.show.refresh
* Add sg.show.pause
* Add sg.show.update
* Add sg.shows
* Add sg.shows.browsetrakt
* Add sg.shows.forceupdate
* Add sg.shows.queue
* Add sg.shows.stats
* Change sickbeard to sickgear
* Change sickbeard_call to property
* Change sg.episode.setstatus allow setting of quality
* Change sg.history, history command output
* Change sg.searchtv to list of indexers
* Add uhd4kweb to qualities
* Add upgrade_once to add existing shows
* Add upgrade_once to add new show
* Add upgrade_once to show quality settings (get/set)
* Add 'ids' to Show + Shows
* Add ids to coming eps + get tvdb id from ids
* Add 'status_str' to coming eps
* Add 'local_datetime' to comming eps + runtime
* Add X-Filename response header to getbanner, getposter
* Add X-Fanartname response header for sg.show.getfanart
[develop changelog]
### 0.14.0 (2018-02-01 02:30:00 UTC)
* Change improve core scheduler logic
* Change improve media process to parse anime format 'Show Name 123 - 001 - Ep 1 name'

View file

@ -3,7 +3,9 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>API Builder</title>
<script type="text/javascript" charset="utf-8">
<link rel="stylesheet" type="text/css" href="$sbRoot/css/style.css?v=$sbPID">
<link rel="stylesheet" type="text/css" href="$sbRoot/css/light.css?v=$sbPID">
<script type="text/javascript" charset="utf-8">
<!--
sbRoot = "$sbRoot";
//-->
@ -18,6 +20,8 @@ sbRoot = "$sbRoot";
#apibuilder select option { padding: 1px 6px; line-height: 1.2em; }
#apibuilder .disabled { color: #ccc; }
#apibuilder .action { background-color: #efefef; }
.parareq {display: block; color: red; font-weight: bolder; font-size: 80%;}
.paraopt {display: block; color: gray; font-size: 80%;}
-->
</style>
@ -27,54 +31,201 @@ var disable_empty_list=true;
addListGroup("api", "Command");
addOption("Command", "SickBeard", "?cmd=sb", 1); //make default
addOption("Command", "SickGear", "?cmd=sg", 1); //make default
addOption("Command", "SickBeard", "?cmd=sb");
addOption("Command", "List Commands", "?cmd=listcommands");
addList("Command", "SickBeard.AddRootDir", "?cmd=sb.addrootdir", "sb.addrootdir", "", "", "action");
addList("Command", "SickGear.AddRootDir", "?cmd=sg.addrootdir", "sb.addrootdir", "", "", "action");
addOption("Command", "SickBeard.CheckScheduler", "?cmd=sb.checkscheduler", "", "", "action");
addOption("Command", "SickGear.CheckScheduler", "?cmd=sg.checkscheduler", "", "", "action");
addList("Command", "SickBeard.DeleteRootDir", "?cmd=sb.deleterootdir", "sb.deleterootdir", "", "", "action");
addList("Command", "SickGear.DeleteRootDir", "?cmd=sg.deleterootdir", "sb.deleterootdir", "", "", "action");
addOption("Command", "SickBeard.ForceSearch", "?cmd=sb.forcesearch", "", "", "action");
addList("Command", "SickGear.ForceSearch", "?cmd=sg.forcesearch", "sg.forcesearch", "", "action");
addOption("Command", "SickGear.SearchQueue", "?cmd=sg.searchqueue", "", "", "action");
addOption("Command", "SickBeard.GetDefaults", "?cmd=sb.getdefaults", "", "", "action");
addOption("Command", "SickGear.GetDefaults", "?cmd=sg.getdefaults", "", "", "action");
addOption("Command", "SickBeard.GetMessages", "?cmd=sb.getmessages", "", "", "action");
addOption("Command", "SickGear.GetMessages", "?cmd=sg.getmessages", "", "", "action");
addOption("Command", "SickGear.GetQualities", "?cmd=sg.getqualities", "", "", "action");
addOption("Command", "SickGear.GetQualityStrings", "?cmd=sg.getqualitystrings", "", "", "action");
addList("Command", "SickGear.GetIndexers", "?cmd=sg.getindexers", "listindexers", "", "action");
addList("Command", "SickGear.GetIndexerIcon", "?cmd=sg.getindexericon", "getindexericon", "", "action");
addList("Command", "SickGear.GetNetworkIcon", "?cmd=sg.getnetworkicon", "getnetworkicon", "", "action");
addOption("Command", "SickBeard.GetRootDirs", "?cmd=sb.getrootdirs", "", "", "action");
addOption("Command", "SickGar.GetRootDirs", "?cmd=sg.getrootdirs", "", "", "action");
addList("Command", "SickBeard.PauseBacklog", "?cmd=sb.pausebacklog", "sb.pausebacklog", "", "", "action");
addList("Command", "SickGear.PauseBacklog", "?cmd=sg.pausebacklog", "sb.pausebacklog", "", "", "action");
addOption("Command", "SickBeard.Ping", "?cmd=sb.ping", "", "", "action");
addOption("Command", "SickGear.Ping", "?cmd=sg.ping", "", "", "action");
addOption("Command", "SickBeard.Restart", "?cmd=sb.restart", "", "", "action");
addOption("Command", "SickGear.Restart", "?cmd=sg.restart", "", "", "action");
addList("Command", "SickBeard.SearchTVDB", "?cmd=sb.searchtvdb", "sb.searchtvdb", "", "", "action");
addList("Command", "SickGear.SearchTV", "?cmd=sg.searchtv", "sg.searchtv", "", "", "action");
addList("Command", "SickBeard.SetDefaults", "?cmd=sb.setdefaults", "sb.setdefaults", "", "", "action");
addOption("Command", "SickBeard.Shutdown", "?cmd=sb.shutdown", "", "", "action");
addList("Command", "SickGear.ListIgnoreWords", "?cmd=sg.listignorewords", "listignorewords", "", "action");
addList("Command", "SickGear.SetIgnoreWords", "?cmd=sg.setignorewords", "setwords", "", "action");
addList("Command", "SickGear.ListRequiredWords", "?cmd=sg.listrequiredwords", "listrequiredwords", "", "action");
addList("Command", "SickGear.SetRequiredWords", "?cmd=sg.setrequiredwords", "setwords", "", "action");
addList("Command", "Coming Episodes", "?cmd=future", "future");
addList("Command", "SickGear - Coming Episodes", "?cmd=sg.future", "future");
addList("Command", "Episode", "?cmd=episode", "episode");
addList("Command", "SickGear.Episode", "?cmd=sg.episode", "sg.episode");
addList("Command", "Episode.Search", "?cmd=episode.search", "episode.search", "", "", "action");
addList("Command", "SickGear.Episode.Search", "?cmd=sg.episode.search", "sg.episode.search", "", "", "action");
addList("Command", "Episode.SetStatus", "?cmd=episode.setstatus", "episode.setstatus", "", "", "action");
addList("Command", "SickGear.Episode.SetStatus", "?cmd=sg.episode.setstatus", "sg.episode.setstatus", "", "", "action");
addList("Command", "Scene Exceptions", "?cmd=exceptions", "exceptions");
addList("Command", "SickGear Scene Exceptions", "?cmd=sg.exceptions", "sg.exceptions");
addList("Command", "Set Scene Exceptions", "?cmd=sg.setexceptions", "changeexceptions", "", "action");
addList("Command", "Set Scene Number", "?cmd=sg.setscenenumber", "setscenenumber", "", "action");
addList("Command", "Activate Scene Numbering", "?cmd=sg.activatescenenumbering", "activatescenenumber", "", "action");
addList("Command", "History", "?cmd=history", "history");
addList("Command", "SickGear History", "?cmd=sg.history", "history");
addOption("Command", "History.Clear", "?cmd=history.clear", "", "", "action");
addOption("Command", "SickGear.History.Clear", "?cmd=sg.history.clear", "", "", "action");
addOption("Command", "History.Trim", "?cmd=history.trim", "", "", "action");
addOption("Command", "SickGear.History.Trim", "?cmd=sg.history.trim", "", "", "action");
addList("Command", "PostProcess", "?cmd=postprocess", "postprocess", "", "","action");
addList("Command", "SickGear PostProcess", "?cmd=sg.postprocess", "postprocess", "", "","action");
addList("Command", "Logs", "?cmd=logs", "logs");
addList("Command", "SickGear Logs", "?cmd=sg.logs", "logs");
addList("Command", "Show", "?cmd=show", "indexerid");
addList("Command", "SickGear.Show", "?cmd=sg.show", "sg.indexerid");
addList("Command", "Show.AddExisting", "?cmd=show.addexisting", "show.addexisting", "", "", "action");
addList("Command", "SickGear.Show.AddExisting", "?cmd=sg.show.addexisting", "sg.show.addexisting", "", "", "action");
addList("Command", "Show.AddNew", "?cmd=show.addnew", "show.addnew", "", "", "action");
addList("Command", "SickGear.Show.AddNew", "?cmd=sg.show.addnew", "sg.show.addnew", "", "", "action");
addList("Command", "Show.Cache", "?cmd=show.cache", "indexerid", "", "", "action");
addList("Command", "SickGear.Show.Cache", "?cmd=sg.show.cache", "sg.indexerid", "", "", "action");
addList("Command", "Show.Delete", "?cmd=show.delete", "indexerid", "", "", "action");
addList("Command", "SickGear.Show.Delete", "?cmd=sg.show.delete", "sg.indexerid", "", "", "action");
addList("Command", "Show.GetBanner", "?cmd=show.getbanner", "indexerid", "", "", "action");
addList("Command", "SickGear.Show.GetBanner", "?cmd=sg.show.getbanner", "sg.indexerid", "", "", "action");
addList("Command", "SickGear.Show.ListFanart", "?cmd=sg.show.listfanart", "sg.indexerid", "", "", "action");
addList("Command", "SickGear.Show.GetFanart", "?cmd=sg.show.getfanart", "sg.indexerid", "", "", "action");
addList("Command", "Show.GetPoster", "?cmd=show.getposter", "indexerid", "", "", "action");
addList("Command", "SickGear.Show.GetPoster", "?cmd=sg.show.getposter", "sg.indexerid", "", "", "action");
addList("Command", "Show.GetQuality", "?cmd=show.getquality", "indexerid", "", "", "action");
addList("Command", "SickGear.Show.GetQuality", "?cmd=sg.show.getquality", "sg.indexerid", "", "", "action");
addList("Command", "Show.Pause", "?cmd=show.pause", "show.pause", "", "", "action");
addList("Command", "SickGear.Show.Pause", "?cmd=sg.show.pause", "sg.show.pause", "", "", "action");
addList("Command", "Show.Refresh", "?cmd=show.refresh", "indexerid", "", "", "action");
addList("Command", "SickGear.Show.Refresh", "?cmd=sg.show.refresh", "sg.indexerid", "", "", "action");
addList("Command", "Show.SeasonList", "?cmd=show.seasonlist", "show.seasonlist", "", "", "action");
addList("Command", "SickGear.Show.SeasonList", "?cmd=sg.show.seasonlist", "sg.show.seasonlist", "", "", "action");
addList("Command", "Show.Seasons", "?cmd=show.seasons", "seasons", "", "", "action");
addList("Command", "SickGear.Show.Seasons", "?cmd=sg.show.seasons", "sg.seasons", "", "", "action");
addList("Command", "Show.SetQuality", "?cmd=show.setquality", "show.setquality", "", "", "action");
addList("Command", "SickGear.Show.SetQuality", "?cmd=sg.show.setquality", "sg.show.setquality", "", "", "action");
addList("Command", "Show.Stats", "?cmd=show.stats", "indexerid", "", "", "action");
addList("Command", "SickGear.Show.Stats", "?cmd=sg.show.stats", "sg.indexerid", "", "", "action");
addList("Command", "Show.Update", "?cmd=show.update", "indexerid", "", "", "action");
addList("Command", "SickGear.Show.Update", "?cmd=sg.show.update", "sg.indexerid", "", "", "action");
addList("Command", "Shows", "?cmd=shows", "shows");
addList("Command", "SickGear.Shows", "?cmd=sg.shows", "shows");
addList("Command", "SickGear.Shows.BrowseTrakt", "?cmd=sg.shows.browsetrakt", "sg.shows.browsetrakt");
addOption("Command", "Shows.ListTraktAccounts", "?cmd=sg.listtraktaccounts", "", "", "action");
addOption("Command", "Shows.Stats", "?cmd=shows.stats", "", "", "action");
addOption("Command", "SickGear.Shows.Stats", "?cmd=sg.shows.stats", "", "", "action");
addOption("Command", "SickGear.Shows.ForceUpdate", "?cmd=sg.shows.forceupdate", "", "", "action");
addOption("Command", "SickGear.Shows.Queue", "?cmd=sg.shows.queue", "", "", "action");
addOption("sg.shows.browsetrakt", "Anticipated", "&type=anticipated");
addOption("sg.shows.browsetrakt", "New Shows", "&type=newshows");
addOption("sg.shows.browsetrakt", "New Seasons", "&type=newseasons");
addOption("sg.shows.browsetrakt", "Popular", "&type=popular");
addOption("sg.shows.browsetrakt", "Trending", "&type=trending");
addList("sg.shows.browsetrakt", "Recommended", "&type=recommended", "sg.traktaccounts");
addList("sg.shows.browsetrakt", "Watchlist", "&type=watchlist", "sg.traktaccounts");
#from sickbeard import TRAKT_ACCOUNTS
#for $a in $TRAKT_ACCOUNTS
addOption("sg.traktaccounts", "$TRAKT_ACCOUNTS[$a].name", "&account_id=$a");
#end for
addOption("sg.forcesearch", "Recent Search", "&searchtype=recent", 1);
addOption("sg.forcesearch", "Backlog Search", "&searchtype=backlog");
addOption("sg.forcesearch", "Proper Search", "&searchtype=proper");
addOption("listindexers", "Optional Param", "", 1);
addOption("listindexers", "Searchable only", "&searchable-only=1");
addOption("getnetworkicon", "CBS", "&network=cbs");
addOption("getnetworkicon", "NBC", "&network=nbc");
addOption("getnetworkicon", "Youtube", "&network=youtube");
addOption("getnetworkicon", "The CW", "&network=the%20cw");
addOption("getnetworkicon", "Crime & Investigation Network", "&network=crime%20%26%20investigation%20network");
#for $i in $indexers
addList("getindexericon", "$indexers[$i]", "&indexer=$i", "");
#end for
#for $curShow in $sortedShowList:
addList("activatescenenumber", "$curShow.name", "&indexerid=$curShow.indexerid&indexer=$curShow.indexer", "scenenumber-active");
#end for
addOption("scenenumber-active", "Activate", "&activate=1");
addOption("scenenumber-active", "Deactivate", "&activate=0");
#for $curShow in $sortedShowList:
addList("setscenenumber", "$curShow.name", "&indexerid=$curShow.indexerid&indexer=$curShow.indexer", "setscene-fseason");
#end for
addOption("listignorewords", "Optional Param", "", 1);
#for $curShow in $sortedShowList:
addOption("listignorewords", "$curShow.name", "&indexerid=$curShow.indexerid&indexer=$curShow.indexer");
#end for
addList("setwords", "Optional Param", "", "addwords");
#for $curShow in $sortedShowList:
addList("setwords", "$curShow.name", "&indexerid=$curShow.indexerid&indexer=$curShow.indexer", "addwords");
#end for
addList("addwords", "Optional Param", "", "removewords");
addList("addwords", "ignore1", "&add=ignore1", "removewords");
addList("addwords", "ignore2, ignore3", "&add=ignore2|ignore3", "removewords");
addList("removewords", "Optional Param", "", "useregex");
addList("removewords", "ignore1", "&remove=ignore1", "useregex");
addList("removewords", "ignore2", "&remove=ignore2", "useregex");
addList("removewords", "ignore2, ignore3", "&remove=ignore2|ignore3", "useregex");
addOption("useregex", "Optional Param", "", 1);
addOption("useregex", "as Regex", "&regex=1");
addOption("useregex", "as Words", "&regex=0");
addOption("listrequiredwords", "Optional Param", "", 1);
#for $curShow in $sortedShowList:
addOption("listrequiredwords", "$curShow.name", "&indexerid=$curShow.indexerid&indexer=$curShow.indexer");
#end for
addList("setscene-fseason", "forSeason", "", "setscene-fepisode", 1);
addList("setscene-fepisode", "forEpisode", "", "setscene-fabsolute", 1);
addList("setscene-fabsolute", "forAbsolute", "", "setscene-season");
addList("setscene-season", "sceneSeason", "", "setscene-episode", 1);
addList("setscene-episode", "sceneEpisode", "", "setscene-absolute", 1);
addList("setscene-absolute", "sceneAbsolute", "", "");
#for $c in range(1, 11):
addList("setscene-fseason", "$c", "&forSeason=$c", "setscene-fepisode");
addList("setscene-fepisode", "$c", "&forEpisode=$c", "setscene-fabsolute");
addList("setscene-fabsolute", "$c", "&forAbsolute=$c", "setscene-season");
addList("setscene-season", "$c", "&sceneSeason=$c", "setscene-episode");
addList("setscene-episode", "$c", "&sceneEpisode=$c", "setscene-absolute");
addList("setscene-absolute", "$c", "&sceneAbsolute=$c", "");
#end for
// addOption("indexerid", "Optional Param", "", 1);
#for $curShow in $sortedShowList:
addOption("indexerid", "$curShow.name", "&indexerid=$curShow.indexerid");
#end for
#for $curShow in $sortedShowList:
addOption("sg.indexerid", "$curShow.name", "&indexer=$curShow.indexer&indexerid=$curShow.indexerid");
#end for
addOption("logs", "Optional Param", "", 1);
addOption("logs", "Debug", "&min_level=debug");
addOption("logs", "Info", "&min_level=info");
@ -109,20 +260,26 @@ addOption("shows", "Show Only Not Paused", "&paused=0");
addOption("shows", "Sort by Show Name", "&sort=name");
addOption("shows", "Sort by TVDB ID", "&sort=id");
addList("show.addexisting", "C:\\temp\\show1", "&location=C:\\temp\\show1", "show.addexisting-indexerid");
addList("show.addexisting", "D:\\Temp\\show2", "&location=D:\\Temp\\show2", "show.addexisting-indexerid");
addList("show.addexisting", "S:\\TV\\Ancient Aliens", "&location=S:\\TV\\Ancient Aliens", "show.addexisting-indexerid");
addList("show.addexisting", "S:\\TV\\Chuck", "&location=S:\\TV\\Chuck", "show.addexisting-indexerid");
addList("sg.show.addexisting", "101501 (Ancient Aliens)", "&indexer=1&indexerid=101501", "show.addexisting-loc");
addList("sg.show.addexisting", "80348 (Chuck)", "&indexer=1&indexerid=80348", "show.addexisting-loc");
addList("show.addexisting-indexerid", "101501 (Ancient Aliens)", "&indexerid=101501", "show.addexisting-opt");
addList("show.addexisting-indexerid", "80348 (Chuck)", "&indexerid=80348", "show.addexisting-opt");
addList("show.addexisting", "101501 (Ancient Aliens)", "&tvdbid=101501", "show.addexisting-loc");
addList("show.addexisting", "80348 (Chuck)", "&tvdbid=80348", "show.addexisting-loc");
addList("show.addexisting-loc", "C:\\temp\\show1", "&location=C:\\temp\\show1", "show.addexisting-opt");
addList("show.addexisting-loc", "D:\\Temp\\show2", "&location=D:\\Temp\\show2", "show.addexisting-opt");
addList("show.addexisting-loc", "S:\\TV\\Ancient Aliens", "&location=S:\\TV\\Ancient Aliens", "show.addexisting-opt");
addList("show.addexisting-loc", "S:\\TV\\Chuck", "&location=S:\\TV\\Chuck", "show.addexisting-opt");
addOption("show.addexisting-opt", "Optional Param", "", 1);
addList("show.addexisting-opt", "No Season Folder", "&season_folder=0", "quality");
addList("show.addexisting-opt", "Use Season Folder", "&season_folder=1", "quality");
addList("show.addnew", "101501 (Ancient Aliens)", "&indexerid=101501", "show.addnew-loc");
addList("show.addnew", "80348 (Chuck)", "&indexerid=80348", "show.addnew-loc");
addList("show.addnew", "101501 (Ancient Aliens)", "&tvdbid=101501", "show.addnew-loc");
addList("show.addnew", "80348 (Chuck)", "&tvdbid=80348", "show.addnew-loc");
addList("sg.show.addnew", "101501 (Ancient Aliens)", "&indexer=1&indexerid=101501", "show.addnew-loc");
addList("sg.show.addnew", "80348 (Chuck)", "&indexer=1&indexerid=80348", "show.addnew-loc");
addOption("show.addnew-loc", "Optional Param", "", 1);
addList("show.addnew-loc", "C:\\Temp", "&location=C:\\temp", "show.addnew-status");
@ -141,52 +298,56 @@ addList("show.addnew-opt", "No Season Folder", "&season_folder=0", "quality");
addList("show.addnew-opt", "Use Season Folder", "&season_folder=1", "quality");
addOptGroup("sb.searchtvdb", "Search by Name");
addList("sb.searchtvdb", "Lost", "&name=Lost", "sb.searchtvdb-lang");
addList("sb.searchtvdb", "office", "&name=office", "sb.searchtvdb-lang");
addList("sb.searchtvdb", "OffiCE", "&name=OffiCE", "sb.searchtvdb-lang");
addList("sb.searchtvdb", "Leno", "&name=leno", "sb.searchtvdb-lang");
addList("sb.searchtvdb", "Top Gear", "&name=Top Gear", "sb.searchtvdb-lang");
addList("sb.searchtvdb", "Lost", "&name=Lost", "");
addList("sb.searchtvdb", "office", "&name=office", "");
addList("sb.searchtvdb", "OffiCE", "&name=OffiCE", "");
addList("sb.searchtvdb", "Leno", "&name=leno", "");
addList("sb.searchtvdb", "Top Gear", "&name=Top Gear", "");
endOptGroup("sb.searchtvdb");
addOptGroup("sb.searchtvdb", "Search by indexerid");
addList("sb.searchtvdb", "73739", "&indexerid=73739", "sb.searchtvdb-lang");
addList("sb.searchtvdb", "74608", "&indexerid=74608", "sb.searchtvdb-lang");
addList("sb.searchtvdb", "199051", "&indexerid=199051", "sb.searchtvdb-lang");
addList("sb.searchtvdb", "123456 (invalid show)", "&indexerid=123456", "sb.searchtvdb-lang");
addList("sb.searchtvdb", "73739", "&indexerid=73739", "");
addList("sb.searchtvdb", "74608", "&indexerid=74608", "");
addList("sb.searchtvdb", "199051", "&indexerid=199051", "");
addList("sb.searchtvdb", "123456 (invalid show)", "&indexerid=123456", "");
endOptGroup("sb.searchtvdb");
addOption("sb.searchtvdb-lang", "Optional Param", "", 1);
addOption("sb.searchtvdb-lang", "Chinese", "&lang=zh"); // 27
addOption("sb.searchtvdb-lang", "Croatian", "&lang=hr"); // 31
addOption("sb.searchtvdb-lang", "Czech", "&lang=cs"); // 28
addOption("sb.searchtvdb-lang", "Danish", "&lang=da"); // 10
addOption("sb.searchtvdb-lang", "Dutch", "&lang=nl"); // 13
addOption("sb.searchtvdb-lang", "English", "&lang=en"); // 7
addOption("sb.searchtvdb-lang", "Finnish", "&lang=fi"); // 11 -- Suomeksi
addOption("sb.searchtvdb-lang", "French", "&lang=fr"); // 17
addOption("sb.searchtvdb-lang", "German", "&lang=de"); // 14
addOption("sb.searchtvdb-lang", "Greek", "&lang=el"); // 20
addOption("sb.searchtvdb-lang", "Hebrew", "&lang=he"); // 24
addOption("sb.searchtvdb-lang", "Hungarian", "&lang=hu"); // 19 -- Magyar
addOption("sb.searchtvdb-lang", "Italian", "&lang=it"); // 15
addOption("sb.searchtvdb-lang", "Japanese", "&lang=ja"); // 25
addOption("sb.searchtvdb-lang", "Korean", "&lang=ko"); // 32
addOption("sb.searchtvdb-lang", "Norwegian", "&lang=no"); // 9
addOption("sb.searchtvdb-lang", "Polish", "&lang=pl"); // 18
addOption("sb.searchtvdb-lang", "Portuguese", "&lang=pt");// 26
addOption("sb.searchtvdb-lang", "Russian", "&lang=ru"); // 22
addOption("sb.searchtvdb-lang", "Slovenian", "&lang=sl"); // 30
addOption("sb.searchtvdb-lang", "Spanish", "&lang=es"); // 16
addOption("sb.searchtvdb-lang", "Swedish", "&lang=sv"); // 8
addOption("sb.searchtvdb-lang", "Turkish", "&lang=tr"); // 21
addOptGroup("sg.searchtv", "Search by Name");
addList("sg.searchtv", "Lost", "&name=Lost", "indexertosearch");
addList("sg.searchtv", "office", "&name=office", "indexertosearch");
addList("sg.searchtv", "OffiCE", "&name=OffiCE", "indexertosearch");
addList("sg.searchtv", "Leno", "&name=leno", "indexertosearch");
addList("sg.searchtv", "Top Gear", "&name=Top Gear", "indexertosearch");
endOptGroup("sg.searchtv");
addOptGroup("sg.searchtv", "Search by indexerid");
addList("sg.searchtv", "73739", "&indexerid=73739", "indexertosearch");
addList("sg.searchtv", "74608", "&indexerid=74608", "indexertosearch");
addList("sg.searchtv", "199051", "&indexerid=199051", "indexertosearch");
addList("sg.searchtv", "123456 (invalid show)", "&indexerid=123456", "indexertosearch");
endOptGroup("sg.searchtv");
addOption("indexertosearch", "Optional Param", "", 1);
addOption("indexertosearch", "All Indexers", "&indexers=-1");
#for $i in $searchindexers
addOption("indexertosearch", "$searchindexers[$i]", "&indexers=$i");
#end for
#for $curShow in $sortedShowList:
addList("seasons", "$curShow.name", "&indexerid=$curShow.indexerid", "seasons-$curShow.indexerid");
#end for
#for $curShow in $sortedShowList:
addList("sg.seasons", "$curShow.name", "&indexer=$curShow.indexer&indexerid=$curShow.indexerid", "seasons-$curShow.indexerid");
#end for
#for $curShow in $sortedShowList:
addList("show.seasonlist", "$curShow.name", "&indexerid=$curShow.indexerid", "show.seasonlist-sort");
#end for
#for $curShow in $sortedShowList:
addList("sg.show.seasonlist", "$curShow.name", "&indexer=$curShow.indexer&indexerid=$curShow.indexerid", "show.seasonlist-sort");
#end for
addOption("show.seasonlist-sort", "Optional Param", "", 1);
addOption("show.seasonlist-sort", "Sort by Ascending", "&sort=asc");
@ -194,6 +355,10 @@ addOption("show.seasonlist-sort", "Sort by Ascending", "&sort=asc");
addList("show.setquality", "$curShow.name", "&indexerid=$curShow.indexerid", "quality");
#end for
#for $curShow in $sortedShowList:
addList("sg.show.setquality", "$curShow.name", "&indexer=$curShow.indexer&indexerid=$curShow.indexerid", "quality");
#end for
//build out generic quality options
addOptGroup("quality", "Quality Templates");
addOption("quality", "SD", "&initial=sdtv|sddvd");
@ -243,6 +408,10 @@ addOption("seasons-$curShow", "$curShowSeason.season", "&season=$curShowSeason.s
#end for
#end for
#for $curShow in $sortedShowList:
addList("sg.episode", "$curShow.name", "&indexer=$curShow.indexer&indexerid=$curShow.indexerid", "episode-$curShow.indexerid");
#end for
#for $curShow in $sortedShowList:
addList("episode", "$curShow.name", "&indexerid=$curShow.indexerid", "episode-$curShow.indexerid");
#end for
@ -250,10 +419,15 @@ addList("episode", "$curShow.name", "&indexerid=$curShow.indexerid", "episode-$c
// build out each show's season+episode list for episode cmd
#for $curShow in $episodeSQLResults:
#for $curShowSeason in $episodeSQLResults[$curShow]:
addList("episode-$curShow", "$curShowSeason.season x $curShowSeason.episode", "&season=$curShowSeason.season&episode=$curShowSeason.episode", "episode-$curShow-full");
addList("episode-$curShow", "$curShowSeason.season x $curShowSeason.episode", "&season=$curShowSeason.season&episode=$curShowSeason.episode", "episode-full");
#end for
addOption("episode-$curShow-full", "Optional Param", "", 1);
addOption("episode-$curShow-full", "Show Full Path", "&full_path=1");
#end for
addOption("episode-full", "Optional Param", "", 1);
addOption("episode-full", "Show Full Path", "&full_path=1");
// build out tvshow list for sg.episode.search
#for $curShow in $sortedShowList:
addList("sg.episode.search", "$curShow.name", "&indexer=$curShow.indexer&indexerid=$curShow.indexerid", "episode.search-$curShow.indexerid");
#end for
// build out tvshow list for episode.search
@ -268,6 +442,31 @@ addOption("episode.search-$curShow", "$curShowSeason.season x $curShowSeason.epi
#end for
#end for
// build out tvshow list for sg.episode.setstatus
#for $curShow in $sortedShowList:
addList("sg.episode.setstatus", "$curShow.name", "&indexer=$curShow.indexer&indexerid=$curShow.indexerid", "sg.episode.setstatus-$curShow.indexerid");
#end for
#for $curShow in $episodeSQLResults:
#for $curShowSeason in $episodeSQLResults[$curShow]:
addList("sg.episode.setstatus-$curShow", "$curShowSeason.season x $curShowSeason.episode", "&season=$curShowSeason.season&episode=$curShowSeason.episode", "sg.episode-status");
#end for
#end for
addList("sg.episode-status", "Wanted", "&status=wanted", "sg.episode.quality");
addList("sg.episode-status", "Skipped", "&status=skipped", "sg.episode.quality");
addList("sg.episode-status", "Archived", "&status=archived", "sg.episode.quality");
addList("sg.episode-status", "Ignored", "&status=ignored", "sg.episode.quality");
addList("sg.episode-status", "Snatched", "&status=snatched", "sg.episode.quality");
addList("sg.episode-status", "Downloaded", "&status=downloaded", "sg.episode.quality");
#from sickbeard.webapi import quality_map
addOption("sg.episode.quality", "Opt Param", 1);
#for $q in $quality_map:
addOption("sg.episode.quality", "$q", "&quality=$q");
#end for
// build out tvshow list for episode.setstatus
#for $curShow in $sortedShowList:
addList("episode.setstatus", "$curShow.name", "&indexerid=$curShow.indexerid", "episode.setstatus-$curShow.indexerid");
@ -276,13 +475,13 @@ addList("episode.setstatus", "$curShow.name", "&indexerid=$curShow.indexerid", "
// build out each show's season+episode list for episode.setstatus cmd
#for $curShow in $episodeSQLResults:
#for $curShowSeason in $episodeSQLResults[$curShow]:
addList("episode.setstatus-$curShow", "$curShowSeason.season x $curShowSeason.episode", "&season=$curShowSeason.season&episode=$curShowSeason.episode", "episode-status-$curShow");
addList("episode.setstatus-$curShow", "$curShowSeason.season x $curShowSeason.episode", "&season=$curShowSeason.season&episode=$curShowSeason.episode", "episode-status");
#end for
addOption("episode-status-$curShow", "Wanted", "&status=wanted");
addOption("episode-status-$curShow", "Skipped", "&status=skipped");
addOption("episode-status-$curShow", "Archived", "&status=archived");
addOption("episode-status-$curShow", "Ignored", "&status=ignored");
#end for
addOption("episode-status", "Wanted", "&status=wanted");
addOption("episode-status", "Skipped", "&status=skipped");
addOption("episode-status", "Archived", "&status=archived");
addOption("episode-status", "Ignored", "&status=ignored");
addOption("future", "Optional Param", "", 1);
addList("future", "Sort by Date", "&sort=date", "future-type");
@ -324,6 +523,28 @@ addOption("exceptions", "Optional Param", "", 1);
addOption("exceptions", "$curShow.name", "&indexerid=$curShow.indexerid");
#end for
addOption("sg.exceptions", "Optional Param", "", 1);
#for $curShow in $sortedShowList:
addOption("sg.exceptions", "$curShow.name", "&indexer=$curShow.indexer&indexerid=$curShow.indexerid");
#end for
#for $curShow in $sortedShowList:
addList("changeexceptions", "$curShow.name", "&indexerid=$curShow.indexerid&indexer=$curShow.indexer", "exceptionforseason");
#end for
addList("exceptionforseason", "All Seasons", "&forseason=-1", "addexceptions");
#for $c in range(1, 11):
addList("exceptionforseason", "All Seasons", "&forseason=$c", "addexceptions");
#end for
addList("addexceptions", "Optional Param", "", "removeexceptions");
addList("addexceptions", "Test Name 1", "&add=Test Name 1", "removeexceptions");
addList("addexceptions", "Test Name 1, Name 2", "&add=Test Name 1|Name 2", "removeexceptions");
addOption("removeexceptions", "Optional Param", "", 1);
addOption("removeexceptions", "Test Name 1", "&remove=Test Name 1");
addOption("removeexceptions", "Test Name 1, Name 2", "&remove=Test Name 1|Name 2");
addOption("sb.pausebacklog", "Optional Param", "", 1);
addOption("sb.pausebacklog", "Pause", "&pause=1");
addOption("sb.pausebacklog", "Unpause", "&pause=0");
@ -343,6 +564,9 @@ addOption("sb.deleterootdir", "S:\\Invalid_Location", "&location=S:\\Invalid_Loc
#for $curShow in $sortedShowList:
addList("show.pause", "$curShow.name", "&indexerid=$curShow.indexerid", "show.pause-opt");
#end for
#for $curShow in $sortedShowList:
addList("sg.show.pause", "$curShow.name", "&indexer=$curShow.indexer&indexerid=$curShow.indexerid", "show.pause-opt");
#end for
addOption("show.pause-opt", "Optional Param", "", 1);
addOption("show.pause-opt", "Unpause", "&pause=0");
addOption("show.pause-opt", "Pause", "&pause=1");
@ -350,7 +574,7 @@ addOption("show.pause-opt", "Pause", "&pause=1");
</script>
</head>
<body onload="initListGroup('api', document.apibuilder.firstlevel, document.apibuilder.secondlevel, document.apibuilder.thirdlevel, document.apibuilder.forthlevel, document.apibuilder.fifthlevel, document.apibuilder.sixthlevel, document.apibuilder.seventhlevel)">
<body style="padding-top: 0 !important;" onload="initListGroup('api', document.apibuilder.firstlevel, document.apibuilder.secondlevel, document.apibuilder.thirdlevel, document.apibuilder.forthlevel, document.apibuilder.fifthlevel, document.apibuilder.sixthlevel, document.apibuilder.seventhlevel, document.apibuilder.eigthlevel)">
<form name="apibuilder" id="apibuilder" action="">
<table align="center">
@ -372,9 +596,10 @@ addOption("show.pause-opt", "Pause", "&pause=1");
<select name="fifthlevel"><option></option></select>
<select name="sixthlevel"><option></option></select>
<select name="seventhlevel"><option></option></select>
<select name="eigthlevel"><option></option></select>
<div style="float: left; ">
<input class="btn" type="button" value="Reset" onclick="resetListGroup('api',1)" />
<input class="btn" type="button" value="Go" onclick="goListGroup(this.form['apikey'].value, this.form['seventhlevel'].value, this.form['sixthlevel'].value, this.form['fifthlevel'].value, this.form['forthlevel'].value, this.form['thirdlevel'].value, this.form['secondlevel'].value, this.form['firstlevel'].value)" />
<input class="btn" type="button" value="Go" onclick="goListGroup(this.form['apikey'].value, this.form['eigthlevel'].value, this.form['seventhlevel'].value, this.form['sixthlevel'].value, this.form['fifthlevel'].value, this.form['forthlevel'].value, this.form['thirdlevel'].value, this.form['secondlevel'].value, this.form['firstlevel'].value)" />
</div>
</td>
</tr>

View file

@ -482,6 +482,7 @@
<span class="component-desc">
<input type="checkbox" name="use_api" class="enabler" id="use_api"#echo ('', $checked)[$sg_var('USE_API')]#>
<p>permit the use of the SickGear (SickBeard) API</p>
<p><b>Old Sickbeard API calls are limited to shows from thetvdb.com. Use new API LINK for full access</b></p>
</span>
</label>
</div>

View file

@ -10,7 +10,7 @@
var _disable_empty_list=false;
var _hide_empty_list=false;
function goListGroup(apikey, L7, L6, L5, L4, L3, L2, L1){
function goListGroup(apikey, L8, L7, L6, L5, L4, L3, L2, L1){
var GlobalOptions = "";
$('.global').each(function(){
var checked = $(this).prop('checked');
@ -26,7 +26,7 @@ function goListGroup(apikey, L7, L6, L5, L4, L3, L2, L1){
});
// handle the show.getposter / show.getbanner differently as they return an image and not json
if (L1 == "?cmd=show.getposter" || L1 == "?cmd=show.getbanner") {
if (L1 == "?cmd=sg.getnetworkicon" || L1 == "?cmd=sg.show.getposter" || L1 == "?cmd=sg.show.getbanner" || L1 == "?cmd=show.getposter" || L1 == "?cmd=show.getbanner" || L1 == "?cmd=sg.getindexericon") {
var imgcache = sbRoot + "/api/" + apikey + "/" + L1 + L2 + GlobalOptions;
var html = imgcache + '<br/><br/><img src="' + sbRoot + '/images/loading16.gif" id="imgcache">';
$('#apiResponse').html(html);
@ -36,14 +36,24 @@ function goListGroup(apikey, L7, L6, L5, L4, L3, L2, L1){
cache: false,
dataType: "html",
success: function (img) {
$('#imgcache').attr('src', imgcache);
$('#imgcache').attr('src', imgcache + "&random=" + Math.random() * 100000000000000000000);
}
})
}
else if (L1 == "?cmd=listcommands")
{
var html = $.ajax({
url: sbRoot + "/api/" + apikey + "/" + L1 + L2 + L3 + L4 + L5 + L6 + L7 + L8 + GlobalOptions,
async: false,
dataType: "html",
}).responseText;
$('#apiResponse').html(html);
}
else {
var html = sbRoot + "/api/" + apikey + "/" + L1 + L2 + L3 + L4 + L5 + L6 + L7 + GlobalOptions + "<br/><pre>";
var html = sbRoot + "/api/" + apikey + "/" + L1 + L2 + L3 + L4 + L5 + L6 + L7 + L8 + GlobalOptions + "<br/><pre>";
html += $.ajax({
url: sbRoot + "/api/" + apikey + "/" + L1 + L2 + L3 + L4 + L5 + L6 + L7 + GlobalOptions,
url: sbRoot + "/api/" + apikey + "/" + L1 + L2 + L3 + L4 + L5 + L6 + L7 + L8 + GlobalOptions,
async: false,
dataType: "html",
}).responseText;
@ -167,7 +177,7 @@ function cs_addL(dis,link,label,css) { this.items[this.items.length]=new cs_link
function cs_addG(label,css) { this.items[this.items.length]=new cs_groupOBJ(label,css); }
function cs_endG() { this.items[this.items.length]=new cs_groupOBJ2(); }
function cs_showMsg(msg) { window.status=msg; }
function cs_showMsg(msg) { console.error(msg); window.status=msg; }
function cs_badContent(n) { cs_goodContent=false; cs_showMsg("["+n+"] Not Found."); }
function _setCookie(name, value) {
@ -636,6 +646,6 @@ function selectOptions(n,opts,mode) {
}
}
}
}
}
}
// ------

View file

@ -125,6 +125,11 @@ class indexerApi(object):
def indexers(self):
return dict((int(x['id']), x['name']) for x in indexerConfig.values() if not x['mapped_only'])
@property
def search_indexers(self):
return dict((int(x['id']), x['name']) for x in indexerConfig.values() if not x['mapped_only'] and
x.get('active') and not x.get('defunct'))
@property
def all_indexers(self):
"""

View file

@ -295,31 +295,35 @@ def load_network_dict(load=True):
# get timezone of a network or return default timezone
def get_network_timezone(network):
def get_network_timezone(network, return_name=False):
if network is None:
return sb_timezone
timezone = None
timezone_name = None
try:
if zoneinfo.ZONEFILENAME is not None:
if not network_dict:
load_network_dict()
try:
timezone = tz.gettz(network_dupes.get(network) or network_dict.get(network.replace(' ', '').lower()),
zoneinfo_priority=True)
except:
timezone_name = network_dupes.get(network) or network_dict.get(network.replace(' ', '').lower())
timezone = tz.gettz(timezone_name, zoneinfo_priority=True)
except (StandardError, Exception):
pass
if timezone is None:
cc = re.search(r'\(([a-z]+)\)$', network, flags=re.I)
try:
timezone = tz.gettz(country_timezones.get(cc.group(1).upper()), zoneinfo_priority=True)
except:
timezone_name = country_timezones.get(cc.group(1).upper())
timezone = tz.gettz(timezone_name, zoneinfo_priority=True)
except (StandardError, Exception):
pass
except:
except (StandardError, Exception):
pass
if return_name:
return timezone if isinstance(timezone, datetime.tzinfo) else sb_timezone, timezone_name
return timezone if isinstance(timezone, datetime.tzinfo) else sb_timezone

View file

@ -113,10 +113,10 @@ class sbdatetime(datetime.datetime):
'july', 'august', 'september', 'october', 'november', 'december'])
@static_or_instance
def convert_to_setting(self, dt=None):
def convert_to_setting(self, dt=None, force_local=False):
obj = (dt, self)[self is not None]
try:
if 'local' == sickbeard.TIMEZONE_DISPLAY:
if force_local or 'local' == sickbeard.TIMEZONE_DISPLAY:
return obj.astimezone(sb_timezone)
except (StandardError, Exception):
pass

View file

@ -694,3 +694,66 @@ def fix_xem_numbering(indexer_id, indexer):
if 0 < len(cl):
my_db = db.DBConnection()
my_db.mass_action(cl)
def set_scene_numbering_helper(indexerid, indexer, forSeason=None, forEpisode=None, forAbsolute=None,
sceneSeason=None, sceneEpisode=None, sceneAbsolute=None):
# sanitize:
indexerid = None if indexerid in [None, 'null', ''] else int(indexerid)
indexer = None if indexer in [None, 'null', ''] else int(indexer)
show_obj = sickbeard.helpers.find_show_by_id(sickbeard.showList, {indexer: indexerid}, no_mapped_ids=True)
if not show_obj:
result = {'success': False}
return result
if not show_obj.is_anime:
for_season = None if forSeason in [None, 'null', ''] else int(forSeason)
for_episode = None if forEpisode in [None, 'null', ''] else int(forEpisode)
scene_season = None if sceneSeason in [None, 'null', ''] else int(sceneSeason)
scene_episode = None if sceneEpisode in [None, 'null', ''] else int(sceneEpisode)
action_log = u'Set episode scene numbering to %sx%s for episode %sx%s of "%s"' \
% (scene_season, scene_episode, for_season, for_episode, show_obj.name)
ep_args = {'show': indexerid, 'season': for_season, 'episode': for_episode}
scene_args = {'indexer_id': indexerid, 'indexer': indexer, 'season': for_season, 'episode': for_episode,
'sceneSeason': scene_season, 'sceneEpisode': scene_episode}
result = {'forSeason': for_season, 'forEpisode': for_episode, 'sceneSeason': None, 'sceneEpisode': None}
else:
for_absolute = None if forAbsolute in [None, 'null', ''] else int(forAbsolute)
scene_absolute = None if sceneAbsolute in [None, 'null', ''] else int(sceneAbsolute)
action_log = u'Set absolute scene numbering to %s for episode %s of "%s"' \
% (scene_absolute, for_absolute, show_obj.name)
ep_args = {'show': indexerid, 'absolute': for_absolute}
scene_args = {'indexer_id': indexerid, 'indexer': indexer, 'absolute_number': for_absolute,
'sceneAbsolute': scene_absolute}
result = {'forAbsolute': for_absolute, 'sceneAbsolute': None}
if ep_args.get('absolute'):
ep_obj = show_obj.getEpisode(absolute_number=int(ep_args['absolute']))
elif None is not ep_args['season'] and None is not ep_args['episode']:
ep_obj = show_obj.getEpisode(int(ep_args['season']), int(ep_args['episode']))
else:
ep_obj = 'Invalid paramaters'
if ep_obj is None:
ep_obj = "Episode couldn't be retrieved"
result['success'] = not isinstance(ep_obj, str)
if result['success']:
logger.log(action_log, logger.DEBUG)
set_scene_numbering(**scene_args)
show_obj.flushEpisodes()
else:
result['errorMessage'] = ep_obj
if not show_obj.is_anime:
scene_numbering = get_scene_numbering(indexerid, indexer, for_season, for_episode)
if scene_numbering:
(result['sceneSeason'], result['sceneEpisode']) = scene_numbering
else:
scene_numbering = get_scene_absolute_numbering(indexerid, indexer, for_absolute)
if scene_numbering:
result['sceneAbsolute'] = scene_numbering
return result

View file

@ -177,10 +177,10 @@ class ShowQueue(generic_queue.GenericQueue):
def addShow(self, indexer, indexer_id, showDir, default_status=None, quality=None, flatten_folders=None,
lang='en', subtitles=None, anime=None, scene=None, paused=None, blacklist=None, whitelist=None,
wanted_begin=None, wanted_latest=None, tag=None, new_show=False, show_name=None):
wanted_begin=None, wanted_latest=None, tag=None, new_show=False, show_name=None, upgrade_once=False):
queueItemObj = QueueItemAdd(indexer, indexer_id, showDir, default_status, quality, flatten_folders, lang,
subtitles, anime, scene, paused, blacklist, whitelist,
wanted_begin, wanted_latest, tag, new_show=new_show, show_name=show_name)
wanted_begin, wanted_latest, tag, new_show=new_show, show_name=show_name, upgrade_once=upgrade_once)
self.add_item(queueItemObj)
@ -238,7 +238,7 @@ class ShowQueueItem(generic_queue.QueueItem):
class QueueItemAdd(ShowQueueItem):
def __init__(self, indexer, indexer_id, showDir, default_status, quality, flatten_folders, lang, subtitles, anime,
scene, paused, blacklist, whitelist, default_wanted_begin, default_wanted_latest, tag,
scheduled_update=False, new_show=False, show_name=None):
scheduled_update=False, new_show=False, show_name=None, upgrade_once=False):
self.indexer = indexer
self.indexer_id = indexer_id
@ -247,6 +247,7 @@ class QueueItemAdd(ShowQueueItem):
self.default_wanted_begin = default_wanted_begin
self.default_wanted_latest = default_wanted_latest
self.quality = quality
self.upgrade_once = upgrade_once
self.flatten_folders = flatten_folders
self.lang = lang
self.subtitles = subtitles
@ -341,6 +342,7 @@ class QueueItemAdd(ShowQueueItem):
self.show.location = self.showDir
self.show.subtitles = self.subtitles if None is not self.subtitles else sickbeard.SUBTITLES_DEFAULT
self.show.quality = self.quality if self.quality else sickbeard.QUALITY_DEFAULT
self.show.archive_firstmatch = self.upgrade_once
self.show.flatten_folders = self.flatten_folders if None is not self.flatten_folders else sickbeard.FLATTEN_FOLDERS_DEFAULT
self.show.anime = self.anime if None is not self.anime else sickbeard.ANIME_DEFAULT
self.show.scene = self.scene if None is not self.scene else sickbeard.SCENE_DEFAULT

File diff suppressed because it is too large Load diff

View file

@ -51,7 +51,7 @@ from sickbeard.helpers import has_image_ext, remove_article, starify
from sickbeard.indexers.indexer_config import INDEXER_TVDB, INDEXER_TVRAGE, INDEXER_TRAKT
from sickbeard.scene_numbering import get_scene_numbering, set_scene_numbering, get_scene_numbering_for_show, \
get_xem_numbering_for_show, get_scene_absolute_numbering_for_show, get_xem_absolute_numbering_for_show, \
get_scene_absolute_numbering
get_scene_absolute_numbering, set_scene_numbering_helper
from sickbeard.name_cache import buildNameCache
from sickbeard.browser import foldersAtPath
from sickbeard.blackandwhitelist import BlackAndWhiteList, short_group_names
@ -145,6 +145,13 @@ class BaseHandler(RequestHandler):
return self.get_secure_cookie('sickgear-session-%s' % helpers.md5_for_text(sickbeard.WEB_PORT))
return True
def getImage(self, image):
if ek.ek(os.path.isfile, image):
mime_type, encoding = MimeTypes().guess_type(image)
self.set_header('Content-Type', mime_type)
with ek.ek(open, image, 'rb') as img:
return img.read()
def showPoster(self, show=None, which=None, api=None):
# Redirect initial poster/banner thumb to default images
if 'poster' == which[0:6]:
@ -175,9 +182,14 @@ class BaseHandler(RequestHandler):
static_image_path = image_file_name
if api:
used_file = ek.ek(os.path.basename, static_image_path)
if static_image_path.startswith('/images'):
used_file = 'default'
static_image_path = ek.ek(os.path.join, sickbeard.PROG_DIR, 'gui', 'slick', static_image_path[1:])
mime_type, encoding = MimeTypes().guess_type(static_image_path)
self.set_header('Content-Type', mime_type)
with open(static_image_path, 'rb') as img:
self.set_header('X-Filename', used_file)
with ek.ek(open, static_image_path, 'rb') as img:
return img.read()
else:
static_image_path = os.path.normpath(static_image_path.replace(sickbeard.CACHE_DIR, '/cache'))
@ -2458,50 +2470,8 @@ class Home(MainHandler):
def setSceneNumbering(self, show, indexer, forSeason=None, forEpisode=None, forAbsolute=None, sceneSeason=None,
sceneEpisode=None, sceneAbsolute=None):
# sanitize:
show = None if show in [None, 'null', ''] else int(show)
indexer = None if indexer in [None, 'null', ''] else int(indexer)
show_obj = sickbeard.helpers.findCertainShow(sickbeard.showList, show)
if not show_obj.is_anime:
for_season = None if forSeason in [None, 'null', ''] else int(forSeason)
for_episode = None if forEpisode in [None, 'null', ''] else int(forEpisode)
scene_season = None if sceneSeason in [None, 'null', ''] else int(sceneSeason)
scene_episode = None if sceneEpisode in [None, 'null', ''] else int(sceneEpisode)
action_log = u'Set episode scene numbering to %sx%s for episode %sx%s of "%s"'\
% (scene_season, scene_episode, for_season, for_episode, show_obj.name)
ep_args = {'show': show, 'season': for_season, 'episode': for_episode}
scene_args = {'indexer_id': show, 'indexer': indexer, 'season': for_season, 'episode': for_episode,
'sceneSeason': scene_season, 'sceneEpisode': scene_episode}
result = {'forSeason': for_season, 'forEpisode': for_episode, 'sceneSeason': None, 'sceneEpisode': None}
else:
for_absolute = None if forAbsolute in [None, 'null', ''] else int(forAbsolute)
scene_absolute = None if sceneAbsolute in [None, 'null', ''] else int(sceneAbsolute)
action_log = u'Set absolute scene numbering to %s for episode %s of "%s"'\
% (scene_absolute, for_absolute, show_obj.name)
ep_args = {'show': show, 'absolute': for_absolute}
scene_args = {'indexer_id': show, 'indexer': indexer, 'absolute_number': for_absolute,
'sceneAbsolute': scene_absolute}
result = {'forAbsolute': for_absolute, 'sceneAbsolute': None}
ep_obj = self._getEpisode(**ep_args)
result['success'] = not isinstance(ep_obj, str)
if result['success']:
logger.log(action_log, logger.DEBUG)
set_scene_numbering(**scene_args)
show_obj.flushEpisodes()
else:
result['errorMessage'] = ep_obj
if not show_obj.is_anime:
scene_numbering = get_scene_numbering(show, indexer, for_season, for_episode)
if scene_numbering:
(result['sceneSeason'], result['sceneEpisode']) = scene_numbering
else:
scene_numbering = get_scene_absolute_numbering(show, indexer, for_absolute)
if scene_numbering:
result['sceneAbsolute'] = scene_numbering
result = set_scene_numbering_helper(show, indexer, forSeason, forEpisode, forAbsolute, sceneSeason,
sceneEpisode, sceneAbsolute)
return json.dumps(result)
@ -2730,7 +2700,7 @@ class NewHomeAddShows(Home):
re.sub(r'([,.!][^,.!]*?)$', '...',
re.sub(r'([.!?])(?=\w)', r'\1 ',
self.encode_html((show.get('overview', '') or '')[:250:].strip()))),
self._get_UWRatio(term, show['seriesname'], show.get('aliases', [])), None, None,
self.get_UWRatio(term, show['seriesname'], show.get('aliases', [])), None, None,
self._make_search_image_url(iid, show)
] for show in shows.itervalues()] for iid, shows in results.iteritems()))
@ -2791,7 +2761,8 @@ class NewHomeAddShows(Home):
('%s.jpg' % show['id'], show['id'])
return img_url
def _get_UWRatio(self, search_term, showname, aliases):
@classmethod
def get_UWRatio(cls, search_term, showname, aliases):
s = fuzz.UWRatio(search_term, showname)
# check aliases and give them a little lower score
for a in aliases:
@ -3452,6 +3423,93 @@ class NewHomeAddShows(Home):
return self.redirect('/home/addShows/%s' % ('trakt_trending', sickbeard.TRAKT_MRU)[any(sickbeard.TRAKT_MRU)])
@staticmethod
def get_trakt_data(url_path, *args, **kwargs):
normalised, filtered = ([], [])
error_msg = None
try:
account = kwargs.get('send_oauth', None)
if account:
account = sickbeard.helpers.tryInt(account)
resp = TraktAPI().trakt_request('%sextended=full,images' % url_path, send_oauth=account)
if resp:
if 'show' in resp[0]:
if 'first_aired' in resp[0]:
for item in resp:
item['show']['first_aired'] = item['first_aired']
del item['first_aired']
normalised = resp
else:
for item in resp:
normalised.append({u'show': item})
del resp
except TraktAuthException as e:
logger.log(u'Pin authorisation needed to connect to Trakt service: %s' % ex(e), logger.WARNING)
error_msg = 'Unauthorized: Get another pin in the Notifications Trakt settings'
except TraktException as e:
logger.log(u'Could not connect to Trakt service: %s' % ex(e), logger.WARNING)
except (IndexError, KeyError):
pass
if not normalised:
error_msg = 'No items in watchlist. Use the "Add to watchlist" button at the Trakt website'
raise Exception(error_msg)
oldest_dt = 9999999
newest_dt = 0
oldest = None
newest = None
for item in normalised:
ignore = '''
((bbc|channel\s*?5.*?|itv)\s*?(drama|documentaries))|bbc\s*?(comedy|music)|music\s*?specials|tedtalks
'''
if re.search(ignore, item['show']['title'].strip(), re.I | re.X):
continue
try:
dt = dateutil.parser.parse(item['show']['first_aired'])
dt_ordinal = dt.toordinal()
dt_string = sbdatetime.sbdatetime.sbfdate(dt)
if dt_ordinal < oldest_dt:
oldest_dt = dt_ordinal
oldest = dt_string
if dt_ordinal > newest_dt:
newest_dt = dt_ordinal
newest = dt_string
tmdbid = item.get('show', {}).get('ids', {}).get('tmdb', 0)
tvdbid = item.get('show', {}).get('ids', {}).get('tvdb', 0)
traktid = item.get('show', {}).get('ids', {}).get('trakt', 0)
images = dict(poster=dict(thumb='imagecache?path=browse/thumb/trakt&filename=%s&tmdbid=%s&tvdbid=%s' %
('%s.jpg' % traktid, tmdbid, tvdbid)))
filtered.append(dict(
premiered=dt_ordinal,
premiered_str=dt_string,
when_past=dt_ordinal < datetime.datetime.now().toordinal(), # air time not yet available 16.11.2015
episode_number='' if 'episode' not in item else item['episode']['number'] or 1,
episode_overview=('' if 'episode' not in item else
item['episode']['overview'].strip() or ''),
episode_season='' if 'episode' not in item else item['episode']['season'] or 1,
genres=('' if 'genres' not in item['show'] else
', '.join(['%s' % v for v in item['show']['genres']])),
ids=item['show']['ids'],
images=images,
overview=('' if 'overview' not in item['show'] or None is item['show']['overview'] else
item['show']['overview'].strip()),
rating=0 < item['show'].get('rating', 0) and
('%.2f' % (item['show'].get('rating') * 10)).replace('.00', '') or 0,
title=item['show']['title'].strip(),
url_src_db='https://trakt.tv/shows/%s' % item['show']['ids']['slug'],
url_tvdb=('', '%s%s' % (sickbeard.indexerApi(INDEXER_TVDB).config['show_url'],
item['show']['ids']['tvdb']))[
isinstance(item['show']['ids']['tvdb'], (int, long))
and 0 < item['show']['ids']['tvdb']],
votes='0' if 'votes' not in item['show'] else item['show']['votes']))
except (StandardError, Exception):
pass
return filtered, oldest, newest
def browse_trakt(self, url_path, browse_title, *args, **kwargs):
browse_type = 'Trakt'
@ -6233,6 +6291,8 @@ class ApiBuilder(MainHandler):
t.seasonSQLResults = seasonSQLResults
t.episodeSQLResults = episodeSQLResults
t.indexers = sickbeard.indexerApi().all_indexers
t.searchindexers = sickbeard.indexerApi().search_indexers
if len(sickbeard.API_KEY) == 32:
t.apikey = sickbeard.API_KEY