Пример #1
0
async def test_app(aresponses):
    """Test app property is handled correctly."""
    aresponses.add(
        MATCH_HOST,
        "/api/system/status",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text=load_fixture("system-status.json"),
        ),
    )

    aresponses.add(
        MATCH_HOST,
        "/api/diskspace",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text=load_fixture("diskspace.json"),
        ),
    )

    async with ClientSession() as session:
        client = Radarr(HOST, API_KEY, session=session)
        await client.update()

        assert client.app
        assert isinstance(client.app, models.Application)
Пример #2
0
async def test_series(aresponses):
    """Test series method is handled correctly."""
    aresponses.add(
        MATCH_HOST,
        "/api/series",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text=load_fixture("series.json"),
        ),
    )

    async with ClientSession() as session:
        client = Radarr(HOST, API_KEY, session=session)
        response = await client.series()

        assert response
        assert isinstance(response, List)

        assert response[0]
        assert isinstance(response[0], models.SeriesItem)
        assert response[0].series
        assert isinstance(response[0].series, models.Series)

        assert response[0].seasons
        assert isinstance(response[0].seasons, List)

        assert response[0].seasons[0]
        assert isinstance(response[0].seasons[0], models.Season)
Пример #3
0
async def test_wanted(aresponses):
    """Test queue method is handled correctly."""
    aresponses.add(
        MATCH_HOST,
        "/api/wanted/missing?sortKey=airDateUtc&page=1&pageSize=10&sortDir=desc",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text=load_fixture("wanted-missing.json"),
        ),
        match_querystring=True,
    )

    async with ClientSession() as session:
        client = Radarr(HOST, API_KEY, session=session)
        response = await client.wanted()

        assert response
        assert isinstance(response, models.WantedResults)

        assert response.page == 1
        assert response.per_page == 10
        assert response.total == 2
        assert response.sort_key == "airDateUtc"
        assert response.sort_dir == "descending"

        assert response.episodes
        assert isinstance(response.episodes, List)
        assert len(response.episodes) == 2

        assert response.episodes[0]
        assert isinstance(response.episodes[0], models.Episode)
Пример #4
0
async def test_update(aresponses):
    """Test update method is handled correctly."""
    aresponses.add(
        MATCH_HOST,
        "/api/system/status",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text=load_fixture("system-status.json"),
        ),
    )

    aresponses.add(
        MATCH_HOST,
        "/api/diskspace",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text=load_fixture("diskspace.json"),
        ),
    )

    aresponses.add(
        MATCH_HOST,
        "/api/diskspace",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text=load_fixture("diskspace.json"),
        ),
    )

    async with ClientSession() as session:
        client = Radarr(HOST, API_KEY, session=session)
        response = await client.update()

        assert response
        assert isinstance(response.info, models.Info)
        assert isinstance(response.disks, List)

        response = await client.update()

        assert response
        assert isinstance(response.info, models.Info)
        assert isinstance(response.disks, List)
Пример #5
0
async def test_command_status(aresponses):
    """Test command_status method is handled correctly."""
    aresponses.add(
        MATCH_HOST,
        "/api/command/368630",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text=load_fixture("command-id.json"),
        ),
    )

    async with ClientSession() as session:
        client = Radarr(HOST, API_KEY, session=session)
        response = await client.command_status(368630)

        assert response
        assert isinstance(response, models.CommandItem)
Пример #6
0
async def test_calendar(aresponses):
    """Test calendar method is handled correctly."""
    aresponses.add(
        MATCH_HOST,
        "/api/calendar?start=2014-01-26&end=2014-01-27",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text=load_fixture("calendar.json"),
        ),
        match_querystring=True,
    )

    async with ClientSession() as session:
        client = Radarr(HOST, API_KEY, session=session)
        response = await client.calendar("2014-01-26", "2014-01-27")

        assert response
        assert isinstance(response, List)

        assert response[0]
        assert isinstance(response[0], models.Episode)
Пример #7
0
async def test_queue(aresponses):
    """Test queue method is handled correctly."""
    aresponses.add(
        MATCH_HOST,
        "/api/queue",
        "GET",
        aresponses.Response(
            status=200,
            headers={"Content-Type": "application/json"},
            text=load_fixture("queue.json"),
        ),
    )

    async with ClientSession() as session:
        client = Radarr(HOST, API_KEY, session=session)
        response = await client.queue()

        assert response
        assert isinstance(response, List)

        assert response[0]
        assert isinstance(response[0], models.QueueItem)
        assert response[0].episode
        assert isinstance(response[0].episode, models.Episode)
Пример #8
0
async def test_loop():
    """Test loop usage is handled correctly."""
    async with Radarr(HOST, API_KEY) as radarr:
        assert isinstance(radarr, Radarr)
Пример #9
0
                      InlineKeyboardMarkup)
from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters,
                          ConversationHandler, CallbackQueryHandler)
import logging
from imdb import IMDb
import os
import random

if os.path.isfile('.env'):
    from dotenv import load_dotenv
    load_dotenv()

radarrApiKey = os.environ.get('RADARR_API_KEY')
sonarrApiKey = os.environ.get('SONARR_API_KEY')
telegram_bot_token = os.environ.get('TELEGRAM_BOT_TOKEN')
raddar = Radarr(radarrApiKey)
sonarr = Sonarr(sonarrApiKey)
seasons_to_add_global = {}
manager_id = os.environ.get('MANAGER_ID', '')  # Telegram manager id
gf_id = os.environ.get('GF_ID', '')
guests_id = os.environ.get('GUESTS_ID', '')
logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.INFO)
logger = logging.getLogger(__name__)

if manager_id != '':
    managers = list(map(int, manager_id.split(',')))
    manager_id = managers[0]

if gf_id != '':