Skip to content

Commit

Permalink
🐛 fix issues with formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
marksie1988 committed Sep 21, 2020
1 parent 9efab46 commit ea283f7
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 258 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ RUN apt upgrade -y

RUN apt install zsh -y

RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python && source
ENV PATH="/root/.poetry/bin:$PATH"
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python && source $HOME/.poetry/env
ENV PATH="$HOME/.poetry/bin:$PATH"

RUN wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O - | zsh || true

Expand Down
148 changes: 76 additions & 72 deletions PyArr/radarr_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,28 @@

class RadarrAPI(RequestAPI):
def __init__(
self, host_url: str, api_key: str,
self,
host_url: str,
api_key: str,
):
"""Constructor requires Host-URL and API-KEY
Args:
host_url (str): Host url to radarr.
api_key: API key from Radarr. You can find this
Args:
host_url (str): Host url to radarr.
api_key: API key from Radarr. You can find this
"""
super().__init__(host_url, api_key)

def getCalendar(self, *args):
"""getCalendar retrieves info about when movies were/will be downloaded.
If start and end are not provided, retrieves movies airing today and tomorrow.
If start and end are not provided, retrieves movies airing today and tomorrow.
args:
start_date (datetime):
end_date (datetime):
args:
start_date (datetime):
end_date (datetime):
Returns:
json response
Returns:
json response
"""
path = "/api/calendar"
Expand All @@ -49,12 +51,12 @@ def getCalendar(self, *args):

def getCommand(self, *args):
"""getCommand Queries the status of a previously
started command, or all currently started commands.
started command, or all currently started commands.
Args:
Optional - id (int) Unique ID of command
Returns:
json response
Args:
Optional - id (int) Unique ID of command
Returns:
json response
"""
if len(args) == 1:
Expand All @@ -68,11 +70,11 @@ def getCommand(self, *args):
def __setCommand(self, data):
"""Private Command Method
Args:
data (dict): data payload to send to /api/command
Args:
data (dict): data payload to send to /api/command
Returns:
json response
Returns:
json response
"""
print(data)
path = "/api/command"
Expand All @@ -82,10 +84,10 @@ def __setCommand(self, data):
def refreshMovie(self, *args):
"""RefreshMovie refreshes movie information and rescans disk.
Args:
Optional - movieId (int)
Returns:
json response
Args:
Optional - movieId (int)
Returns:
json response
"""
data = {}
Expand All @@ -98,10 +100,10 @@ def refreshMovie(self, *args):
def rescanMovie(self, *args):
"""RescanMovie scans disk for any downloaded movie for all or specified movie.
Args:
Optional - movieId (int)
Returns:
json response
Args:
Optional - movieId (int)
Returns:
json response
"""
data = {}
Expand All @@ -114,10 +116,10 @@ def rescanMovie(self, *args):
def syncRss(self):
"""Instruct Sonarr to perform an RSS sync with all enabled indexers
Args:
none
Returns:
json response
Args:
none
Returns:
json response
"""
data = {"name": "RssSync"}
Expand All @@ -126,10 +128,10 @@ def syncRss(self):
def getDiskSpace(self):
"""GetDiskSpace retrieves info about the disk space on the server.
Args:
None
Returns:
json response
Args:
None
Returns:
json response
"""
path = "/api/diskspace"
Expand All @@ -139,10 +141,10 @@ def getDiskSpace(self):
def getMovie(self, *args):
"""getMovie returns all movies in collection.
Args:
Optional - id (int) ID of movie
Returns:
json response
Args:
Optional - id (int) ID of movie
Returns:
json response
"""
if len(args) == 1:
Expand All @@ -156,10 +158,10 @@ def getMovie(self, *args):
def lookupMovie(self, term):
"""lookupMovie serches for movie
Args:
Requried - term / tmdbId / imdbId
Returns:
json response
Args:
Requried - term / tmdbId / imdbId
Returns:
json response
"""
term = str(term)
Expand Down Expand Up @@ -188,12 +190,12 @@ def getQualityProfiles(self):
def constructMovieJson(self, dbId, qualityProfileId):
"""Searches for movie on tmdb and returns Movie json to add
Args:
Required - dbID, <imdb or tmdb id>
Required - qualityProfileId (int)
Args:
Required - dbID, <imdb or tmdb id>
Required - qualityProfileId (int)
Return:
JsonArray
Return:
JsonArray
"""
s_dict = self.lookupMovie(dbId)
Expand All @@ -216,11 +218,11 @@ def constructMovieJson(self, dbId, qualityProfileId):
def addMovie(self, dbId, qualityProfileId):
"""addMovie adds a new movie to collection
Args:
Required - dbid
Required - qualityProfileId
Returns:
json response
Args:
Required - dbid
Required - qualityProfileId
Returns:
json response
"""
movie_json = self.constructMovieJson(dbId, qualityProfileId)
Expand All @@ -231,12 +233,12 @@ def addMovie(self, dbId, qualityProfileId):

def delMovie(self, movieId, delFiles=False, addExclusion=False):
"""Delete the movie with the given ID
Args:
Required - movieId (int)
Optional - delFiles (bool)
Optional - addExclusion (bool)
Returns:
json response
Args:
Required - movieId (int)
Optional - delFiles (bool)
Optional - addExclusion (bool)
Returns:
json response
"""
# File deletion does not work
Expand All @@ -261,17 +263,19 @@ def getQueue(self):
def delQueue(self, id, *args):
"""Deletes an item from the queue and download client. Optionally blacklist item after deletion.
Args:
Required - id (int)
Optional - blacklist (bool)
Returns:
json response
Args:
Required - id (int)
Optional - blacklist (bool)
Returns:
json response
"""
data = {}
data.update({"id": id})
if len(args) == 1:
data.update(
{"blacklist": args[1],}
{
"blacklist": args[1],
}
)
path = "/api/queue/"
res = self.request_del(path, data)
Expand All @@ -280,13 +284,13 @@ def delQueue(self, id, *args):
def getHistory(self, page, **kwargs):
"""Gets history (grabs/failures/completed)
Args:
Required - page (int) - 1-indexed (1 default)
Optional - sortKey (string) - movie.title or date
Optional - pageSize (int) - Default: 0
Optional - sortDir (string) - asc or desc - Default: asc
Returns:
json response
Args:
Required - page (int) - 1-indexed (1 default)
Optional - sortKey (string) - movie.title or date
Optional - pageSize (int) - Default: 0
Optional - sortDir (string) - asc or desc - Default: asc
Returns:
json response
"""
data = {}
data.update({"page": kwargs.get("page", 1)})
Expand Down
48 changes: 25 additions & 23 deletions PyArr/request_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

class RequestAPI:
def __init__(
self, host_url: str, api_key: str,
self,
host_url: str,
api_key: str,
):
"""Constructor requires Host-URL and API-KEY
Args:
host_url (str): Host url to sonarr.
api_key: API key from Sonarr. You can find this
Args:
host_url (str): Host url to sonarr.
api_key: API key from Sonarr. You can find this
"""
self.host_url = host_url
self.api_key = api_key
Expand All @@ -34,11 +36,11 @@ def basic_auth(self, username, password):

def request_get(self, path, **kwargs):
"""Wrapper on the session.get
Kwargs:
**kwargs: Any url attributes to add to the request.
Kwargs:
**kwargs: Any url attributes to add to the request.
Returns:
requests.models.Response: Response object form requests.
Returns:
requests.models.Response: Response object form requests.
"""
headers = {"X-Api-Key": self.api_key}
request_url = "{url}{path}".format(url=self.host_url, path=path)
Expand All @@ -55,12 +57,12 @@ def request_get(self, path, **kwargs):
def request_post(self, path, data):
"""Wrapper on the requests.post
Args:
path (str): Path to API. E.g. /api/manualimport
data (dict): data payload to send with request.
Args:
path (str): Path to API. E.g. /api/manualimport
data (dict): data payload to send with request.
Returns:
requests.models.Response: Response object form requests.
Returns:
requests.models.Response: Response object form requests.
"""
headers = {"X-Api-Key": self.api_key}
request_url = "{url}{path}".format(url=self.host_url, path=path)
Expand All @@ -70,12 +72,12 @@ def request_post(self, path, data):
def request_put(self, path, data):
"""Wrapper on the requests.put
Args:
path (str): Path to API. E.g. /api/manualimport
data (dict): data payload to send with request.
Args:
path (str): Path to API. E.g. /api/manualimport
data (dict): data payload to send with request.
Returns:
requests.models.Response: Response object form requests.
Returns:
requests.models.Response: Response object form requests.
"""
headers = {"X-Api-Key": self.api_key}
request_url = "{url}{path}".format(url=self.host_url, path=path)
Expand All @@ -85,12 +87,12 @@ def request_put(self, path, data):
def request_del(self, path, data):
"""Wrapper on the requests.delete
Args:
path (str): Path to API. E.g. /api/manualimport
data (dict): data payload to send with request.
Args:
path (str): Path to API. E.g. /api/manualimport
data (dict): data payload to send with request.
Returns:
res (Request Response Object)
Returns:
res (Request Response Object)
"""
headers = {"X-Api-Key": self.api_key}
request_url = "{url}{path}".format(url=self.host_url, path=path)
Expand Down
Loading

0 comments on commit ea283f7

Please sign in to comment.