Esempio n. 1
0
 def run(self, cli: base_media.BaseCliMediaApi, args: Namespace) -> None:
     super().run(cli, args)
     res = cli.get_quality_profiles()
     print("Available quality profiles:\n")
     for profile in res:
         qualities = ",".join([qual["quality"]["name"] for qual in profile["items"] if qual["allowed"]])
         print(f"{profile['id']}: {profile['name']} ({qualities})")
Esempio n. 2
0
def select_language_profile(cli: base_media.BaseCliMediaApi) -> int:
    res = cli.get_language_profiles()
    for profile in res:
        print(f"[{profile['id']}]: {profile['name']}")
    profile_id = input(f"Profile id to use (1-{len(res)}):")
    if profile_id.isdigit():
        return int(profile_id)
    else:
        raise Exception("Invalid profile selection: {}")
Esempio n. 3
0
    def run(self, cli: base_media.BaseCliMediaApi, args: Namespace) -> None:
        super().run(cli, args)

        # Use json data from argument by default, but load json file if specified
        if args.file:
            with open(args.file, "r") as f:
                notification_data = json.load(f)
        else:
            notification_data = json.loads(args.json)

        res = cli.put_notification(args.id, notification_data)
        print(f"{pformat(res)}\n")
Esempio n. 4
0
    def run(self, cli: base_media.BaseCliMediaApi, args: Namespace) -> None:
        super().run(cli, args)
        res = None
        if args.label:
            tags = cli.get_tag_detail()
            for tag in tags:
                if tag["label"] == args.label:
                    res = tag
        else:
            res = cli.get_tag_detail(args.id)

        if res:
            print(f"Items with tag \"{res['label']}\" ({res['id']}):")
            if "seriesIds" in res:
                for tag_item in res["seriesIds"]:
                    item = cli.get_serie(tag_item)
                    print(f"    {item.title} ({item.year})")
            elif "movieIds" in res:
                for tag_item in res["movieIds"]:
                    item = cli.get_movie(tag_item)
                    print(f"    {item.title} ({item.year})")
        else:
            print("no such tag")
Esempio n. 5
0
def select_profile(cli: base_media.BaseCliMediaApi) -> int:
    res = cli.get_quality_profiles()
    for profile in res:
        qualities = []
        for qual in profile["items"]:
            if qual["allowed"]:
                # Quality items
                if "quality" in qual:
                    qualities.append(qual["quality"]["name"])
                # Quality groups
                elif "name" in qual:
                    qualities.append(qual["name"])
        print(f"[{profile['id']}]: {profile['name']} ({qualities})")
    profile_id = input(f"Profile id to use (1-{len(res)}):")
    if profile_id.isdigit():
        return int(profile_id)
    else:
        raise Exception("Invalid profile selection: {}")
Esempio n. 6
0
 def run(self, cli: base_media.BaseCliMediaApi, args: Namespace) -> None:
     super().run(cli, args)
     res = cli.delete_exclusion(args.id)
     print(f"{pformat(res)}\n")
Esempio n. 7
0
 def run(self, cli: base_media.BaseCliMediaApi, args: Namespace) -> None:
     super().run(cli, args)
     res = cli.create_tag(args.label)
     print(f"{pformat(res)}\n")
Esempio n. 8
0
 def run(self, cli: base_media.BaseCliMediaApi, args: Namespace) -> None:
     super().run(cli, args)
     res = cli.get_tag_detail(args.id)
     print(f"{pformat(res)}\n")
Esempio n. 9
0
 def run(self, cli: base_media.BaseCliMediaApi, args: Namespace) -> None:
     super().run(cli, args)
     res = cli.get_blocklist(
         page=args.page, sort_key=args.sort_key, page_size=args.page_size, sort_dir=args.sort_dir
     )
     print(f"{pformat(res)}\n")
Esempio n. 10
0
 def run(self, cli: base_media.BaseCliMediaApi, args: Namespace) -> None:
     super().run(cli, args)
     start_date = datetime.datetime.strptime(args.start, "%Y-%m-%d") if args.start else None
     end_date = datetime.datetime.strptime(args.end, "%Y-%m-%d") if args.end else None
     res = cli.get_calendar(start_date=start_date, end_date=end_date)
     print(f"{pformat(res)}\n")
Esempio n. 11
0
 def run(self, cli: base_media.BaseCliMediaApi, args: Namespace) -> None:
     super().run(cli, args)
     res = cli.get_queue(args.page, args.sort_key, args.page_size, args.sort_dir, not args.exclude_unknown)
     print(f"{pformat(res)}\n")
Esempio n. 12
0
 def run(self, cli: base_media.BaseCliMediaApi, args: Namespace) -> None:
     super().run(cli, args)
     res = cli.get_disk_space()
     print(f"{pformat(res)}\n")
Esempio n. 13
0
def cli():
    return BaseCliMediaApi(TEST_HOST, TEST_APIKEY)