Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Add optional full episode output to season list in API #441

Open
wants to merge 1 commit into from

3 participants

pleo1 Nic Wolfe Jacksonville
pleo1
pleo1 commented July 22, 2012

I modified the show.seasons API method to accept an optional full parameter which allows the description and location to be included in the season list in addition to the current fields. The original behavior of this method is unchanged, as full=0 is the default.

Nic Wolfe
Owner

Please submit this against the development branch, all new features go there now. And thanks.

Jacksonville

This is exactly what I was looking for. Thanks for sharing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 22, 2012
pleo1 Added full output option to season list in API. 8226b56
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 14 additions and 2 deletions. Show diff stats Hide diff stats

  1. 16  sickbeard/webapi.py
16  sickbeard/webapi.py
@@ -2035,6 +2035,7 @@ class CMD_ShowSeasons(ApiCall):
2035 2035
              "requiredParameters": {"tvdbid": {"desc": "thetvdb.com unique id of a show"},
2036 2036
                                   },
2037 2037
              "optionalParameters": {"season": {"desc": "the season number"},
  2038
+                                    "full": {"desc": "include full episode details"}
2038 2039
                                   }
2039 2040
              }
2040 2041
 
@@ -2043,6 +2044,7 @@ def __init__(self, args, kwargs):
2043 2044
         self.tvdbid, args = self.check_params(args, kwargs, "tvdbid", None, True, "int", [])
2044 2045
         # optional
2045 2046
         self.season, args = self.check_params(args, kwargs, "season", None, False, "int", [])
  2047
+        self.full, args = self.check_params(args, kwargs, "full", False, False, "bool", [])
2046 2048
         # super, missing, help
2047 2049
         ApiCall.__init__(self, args, kwargs)
2048 2050
 
@@ -2053,9 +2055,17 @@ def run(self):
2053 2055
             return _responds(RESULT_FAILURE, msg="Show not found")
2054 2056
 
2055 2057
         myDB = db.DBConnection(row_type="dict")
  2058
+        query = {
  2059
+            "select": "name, episode, airdate, status, season",
  2060
+            "where":  "showid = ?",
  2061
+            "args":   [self.tvdbid]
  2062
+        }
  2063
+
  2064
+        if self.full:
  2065
+            query["select"] += ", description, location"
2056 2066
 
2057 2067
         if self.season == None:
2058  
-            sqlResults = myDB.select("SELECT name, episode, airdate, status, season FROM tv_episodes WHERE showid = ?", [self.tvdbid])
  2068
+            sqlResults = myDB.select("SELECT %(select)s FROM tv_episodes WHERE %(where)s" % query, query["args"])
2059 2069
             seasons = {}
2060 2070
             for row in sqlResults:
2061 2071
                 status, quality = Quality.splitCompositeStatus(int(row["status"]))
@@ -2071,7 +2081,9 @@ def run(self):
2071 2081
                 seasons[curSeason][curEpisode] = row
2072 2082
 
2073 2083
         else:
2074  
-            sqlResults = myDB.select("SELECT name, episode, airdate, status FROM tv_episodes WHERE showid = ? AND season = ?", [self.tvdbid, self.season])
  2084
+            query["where"] += " AND season = ?"
  2085
+            query["args"].append(self.season)
  2086
+            sqlResults = myDB.select("SELECT %(select)s FROM tv_episodes WHERE %(where)s" % query, query["args"])
2075 2087
             if len(sqlResults) is 0:
2076 2088
                 return _responds(RESULT_FAILURE, msg="Season not found")
2077 2089
             seasons = {}
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.