예제 #1
0
def addToLibrary(tvdbId, path):
    parameters = {"term": "tvdb:" + str(tvdbId)}
    req = requests.get(commons.generateApiQuery("sonarr", "series/lookup", parameters))
    parsed_json = json.loads(req.text)
    data = json.dumps(buildData(parsed_json, path))
    add = requests.post(commons.generateApiQuery("sonarr", "series"), data=data, headers={'Content-Type': 'application/json'})
    if add.status_code == 201:
        return True
    else:
        return False
예제 #2
0
def addToLibrary(tmdbId, path):
    parameters = {"tmdbId": str(tmdbId)}
    req = requests.get(
        commons.generateApiQuery("radarr", "movie/lookup/tmdb", parameters))
    parsed_json = json.loads(req.text)
    data = json.dumps(buildData(parsed_json, path))
    add = requests.post(commons.generateApiQuery("radarr", "movie"), data=data)
    if add.status_code == 201:
        return True
    else:
        return False
예제 #3
0
def addToLibrary(tvdbId):
    parameters = {"term": "tvdb:" + str(tvdbId)}
    req = requests.get(
        commons.generateApiQuery('sonarr', 'series/lookup', parameters))
    parsed_json = json.loads(req.text)
    data = json.dumps(buildData(parsed_json))
    add = requests.post(commons.generateApiQuery('sonarr', 'series'),
                        data=data)
    if add.status_code == 201:
        return True
    else:
        return False
예제 #4
0
def addToLibrary(tmdbId, path, qualityProfileId, tags):
    parameters = {"tmdbId": str(tmdbId)}
    req = requests.get(
        commons.generateApiQuery("radarr", "movie/lookup/tmdb", parameters)
    )
    parsed_json = json.loads(req.text)
    data = json.dumps(buildData(parsed_json, path, qualityProfileId, tags))
    add = requests.post(commons.generateApiQuery("radarr", "movie"), data=data, headers={'Content-Type': 'application/json'})
    if add.status_code == 201:
        return True
    else:
        return False
예제 #5
0
def changeSpeedSabnzbd(update, context):
    if not checkId(update):
        if (authentication(
                update,
                context) == "added"):  # To also stop the beginning command
            return ConversationHandler.END

    choice = update.callback_query.data

    url = generateApiQuery("sabnzbd", "", {
        'output': 'json',
        'mode': 'config',
        'name': 'speedlimit',
        'value': choice
    })

    req = requests.get(url)
    message = None
    if req.status_code == 200:
        if choice == SABNZBD_SPEED_LIMIT_100:
            message = i18n.t("addarr.Sabnzbd.ChangedTo100")
        elif choice == SABNZBD_SPEED_LIMIT_50:
            message = i18n.t("addarr.Sabnzbd.ChangedTo50")
        elif choice == SABNZBD_SPEED_LIMIT_25:
            message = i18n.t("addarr.Sabnzbd.ChangedTo25")

    else:
        message = i18n.t("addarr.Sabnzbd.Error")

    context.bot.send_message(
        chat_id=update.effective_message.chat_id,
        text=message,
    )

    return ConversationHandler.END
예제 #6
0
파일: sonarr.py 프로젝트: sethyx/Addarr
def inLibrary(tvdbId):
    parameters = {}
    req = requests.get(commons.generateApiQuery("sonarr", "series",
                                                parameters))
    parsed_json = json.loads(req.text)
    return next((True for show in parsed_json if show["tvdbId"] == tvdbId),
                False)
예제 #7
0
def getRootFolders():
    parameters = {}
    req = requests.get(
        commons.generateApiQuery("radarr", "Rootfolder", parameters))
    parsed_json = json.loads(req.text)
    logger.debug(f"Found Radarr paths: {parsed_json}")
    return parsed_json
예제 #8
0
def lookupSeriesByName(series_name):
    params = { # Set query parameters
        'term': series_name
    }

    # Perform Get request from Sonarr API
    req = requests.get(commons.generateApiQuery('sonarr', 'series/lookup', params))
    parsed_json = json.loads(req.text)
    return parsed_json
예제 #9
0
def removeFromLibrary(tvdbId):
    parameters = {"deleteFiles": str(True)}
    dbId = getDbIdFromImdbId(tvdbId)
    delete = requests.delete(
        commons.generateApiQuery("sonarr", f"series/{dbId}", parameters))
    if delete.status_code == 200:
        return True
    else:
        return False
예제 #10
0
def lookupSeriesByTvdbId(tvdb_id):
    params = { # Set query parameters
        'term': 'tvdb:' + str(int(tvdb_id))
    }

    # Perform Get request from Sonarr API
    req = requests.get(commons.generateApiQuery('sonarr', 'series/lookup', params))
    parsed_json = json.loads(req.text)
    return parsed_json
예제 #11
0
def search(title):
    parameters = {"term": title}
    req = requests.get(commons.generateApiQuery("radarr", "movie/lookup", parameters))
    parsed_json = json.loads(req.text)

    if req.status_code == 200 and parsed_json:
        return parsed_json
    else:
        return False
예제 #12
0
def inLibrary(tmdbId):
    parameters = {}
    req = requests.get(commons.generateApiQuery('radarr', 'movie', parameters))
    parsed_json = json.loads(req.text)
    for movie in parsed_json:
        if movie['tmdbId'] == tmdbId:
            return True
            break
    return False
예제 #13
0
def getUpcoming(days):
    todays_date = datetime.date.today()
    weeks_end_date = todays_date + datetime.timedelta(days=int(days))

    params = {
        'start': str(todays_date),
        'end': str(weeks_end_date)
    }
    req = requests.get(commons.generateApiQuery('sonarr', 'calendar', params))
    return json.loads(req.text)
예제 #14
0
def inLibrary(tvdbId):
    parameters = {}
    req = requests.get(commons.generateApiQuery('sonarr', 'series',
                                                parameters))
    parsed_json = json.loads(req.text)
    for show in parsed_json:
        if show['tvdbId'] == tvdbId:
            return True
            break
    return False
예제 #15
0
def search(title):
    parameters = {"term": title}
    req = requests.get(
        commons.generateApiQuery('sonarr', 'series/lookup', parameters))
    parsed_json = json.loads(req.text)

    if req.status_code == 200:
        return parsed_json
    else:
        return False
예제 #16
0
def createTag(tag):
    data_json = {
        "id": max([t["id"] for t in getTags()])+1,
        "label": str(tag)
    }
    add = requests.post(commons.generateApiQuery("radarr", "tag"), json=data_json, headers={'Content-Type': 'application/json'})
    if add.status_code == 200:
        return True
    else:
        return False
예제 #17
0
def getRootFolders():
    parameters = {}
    req = requests.get(commons.generateApiQuery("sonarr", "Rootfolder", parameters))
    parsed_json = json.loads(req.text)
    # Remove unmappedFolders from rootFolder data--we don't need that
    for item in [
        item for item in parsed_json if item.get("unmappedFolders") is not None
    ]:
        item.pop("unmappedFolders")
    logger.debug(f"Found sonarr paths: {parsed_json}")
    return parsed_json
예제 #18
0
def getLanguageProfileId(language):
    parameters = {}
    req = requests.get(
        commons.generateApiQuery("sonarr", "languageProfile", parameters))
    parsed_json = json.loads(req.text)
    languageId = [l["id"] for l in parsed_json if l["name"] == language]
    if len(languageId) == 0:
        languageId = [l["id"] for l in parsed_json]
        logger.debug(
            "Didn't find a match with languageProfile from the config file. Took instead the first languageId from languageProfile-API response"
        )
    return languageId[0]
예제 #19
0
파일: sonarr.py 프로젝트: sethyx/Addarr
def allSeries():
    parameters = {}
    req = requests.get(commons.generateApiQuery("sonarr", "series",
                                                parameters))
    parsed_json = json.loads(req.text)

    if req.status_code == 200:
        data = []
        for show in parsed_json:
            if all(x in show
                   for x in ["title", "year", "monitored", "status"]):
                data.append({
                    "title": show["title"],
                    "year": show["year"],
                    "monitored": show["monitored"],
                    "status": show["status"],
                })
        return data
    else:
        return False
예제 #20
0
def all_movies():
    parameters = {}
    req = requests.get(commons.generateApiQuery("radarr", "movie", parameters))
    parsed_json = json.loads(req.text)

    if req.status_code == 200:
        data = []
        for movie in parsed_json:
            if all(
                x in movie
                for x in ["title", "year", "monitored", "status"]
            ):
                data.append(
                    {
                        "title": movie["title"],
                        "year": movie["year"],
                        "monitored": movie["monitored"],
                        "status": movie["status"]
                    }
                )
        return data
    else:
        return False
예제 #21
0
def inLibrary(tmdbId):
    parameters = {}
    req = requests.get(commons.generateApiQuery("radarr", "movie", parameters))
    parsed_json = json.loads(req.text)
    return next((True for movie in parsed_json if movie["tmdbId"] == tmdbId), False)
예제 #22
0
def getRootFolders():
    parameters = {}
    req = requests.get(commons.generateApiQuery("radarr", "Rootfolder", parameters))
    parsed_json = json.loads(req.text)
    return parsed_json
예제 #23
0
def getSeries():
    req = requests.get(commons.generateApiQuery('sonarr', 'series'))
    parsed_json = json.loads(req.text)
    return parsed_json
예제 #24
0
def getSeriesById(series_id):
    req = requests.get(commons.generateApiQuery('sonarr', 'series/' + str(series_id)))
    parsed_json = json.loads(req.text)
    return parsed_json
예제 #25
0
def addSeriesToWatchList(requested_series):
    response = ''
    context_list = []

    # Check to see if match is already in Sonarr
    my_shows = getSeries()

    for series in requested_series:
        print 'requested_series: '
        print series
        for show in my_shows:
            if int(series['tvdbId']) == int(show['tvdbId']):
                response = 'Looks like Sonarr is already watching for ' + series['title']
            else:
                data = { # Generate data query
                    'tvdbId': int(series['tvdbId']),
                    'title': series['title'],
                    'qualityProfileId': 3,
                    'titleSlug': series['titleSlug'],
                    'images': series['images'],
                    'seasons': series['seasons'],
                    'monitored': True,
                    'seasonFolder': True,
                    'path': '/Volumes/Plex Media 1/Plex/TV Shows/' + series['title']
                }

                # Convert to JSON
                data_json = json.dumps(data)

                # Submit request to API
                r = requests.post(commons.generateApiQuery('sonarr', 'series'), data=data_json)
                parsed_json = json.loads(r.text)

                #  Set user Response
                response = 'Success! ' + series['title'] + ' has been added to Sonarr.'

    # Create Rich Notifications
    slack_message = {
        'attachments': [{
            'fallback': response,
            "pretext": "Message from Comandarr: " + response,
            'author_name': 'Sonarr',
<<<<<<< HEAD
            "author_link": generateServerAddress('sonarr') + '/series/' + series['titleSlug'],
=======
            "author_link": commons.generateServerAddress() + '/series/' + series['titleSlug'],
>>>>>>> origin/develop
            "author_icon": config['sonarr']['resources']['app_logo'],
            'title': 'Imported: ' + series['title'],
            # 'text': series['overview'],
            'color': 'good',
            "fields": [
                {
                    "title": "Number of Seasons",
                    "value": str(series['seasonCount']),
                    "short": 'true'
                },
                {
                    "title": "Monitored",
                    "value": str(series['monitored']),
                    "short": 'true'
                }
            ],
            "thumb_url": config['sonarr']['resources']['app_logo'],
        }]
    }
예제 #26
0
def performCmdRescanSeries():
    req = requests.get(commons.generateApiQuery('sonarr', 'command'))
    parsed_json = json.loads(req.text)
    return parsed_json
예제 #27
0
def getQualityProfiles():
    parameters = {}
    req = requests.get(
        commons.generateApiQuery("sonarr", "qualityProfile", parameters))
    parsed_json = json.loads(req.text)
    return parsed_json
예제 #28
0
def getTags():
    parameters = {}
    req = requests.get(commons.generateApiQuery("sonarr", "tag", parameters))
    parsed_json = json.loads(req.text)
    return parsed_json
예제 #29
0
def getSeasons(tvdbId):
    parameters = {"term": "tvdb:" + str(tvdbId)}
    req = requests.get(
        commons.generateApiQuery("sonarr", "series/lookup", parameters))
    parsed_json = json.loads(req.text)
    return parsed_json[0]["seasons"]
예제 #30
0
def getDbIdFromImdbId(tvdbId):
    req = requests.get(commons.generateApiQuery("sonarr", "series", {}))
    parsed_json = json.loads(req.text)
    dbId = [f["id"] for f in parsed_json if f["tvdbId"] == tvdbId]
    return dbId[0]