Skip to content

Introduction

Background

This is the very first version of the API. Some parts of it scrape data from HTML-formatted pages, while others fetch data directly from the REST API server.

Download Movie

This can be done in a very straightforward way:

from moviebox_api.v1 import MovieAuto


async def main():
    auto = MovieAuto()
    movie_file, subtitle_file = await auto.run("Avatar")
    print(f"Movie: {movie_file.saved_to}")
    print(f"Subtitle: {subtitle_file.saved_to}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())
from moviebox_api.v1 import MovieAuto


def main():
    auto = MovieAuto()
    movie_file, subtitle_file = auto.run_sync("Avatar")
    print(f"Movie: {movie_file.saved_to}")
    print(f"Subtitle: {subtitle_file.saved_to}")


if __name__ == "__main__":
    main()

Behind the scenes, this script does the following:

  1. Performs a movie search
  2. Presents the search results for the user to select one
  3. Downloads both the movie and subtitle files

Download with Progress Callback

from moviebox_api.v1 import DownloadTracker, MovieAuto


async def progress_callback(progress: DownloadTracker):
    percent = (progress.downloaded_size / progress.expected_size) * 100
    print(f"[{percent:.2f}%] Downloading {progress.saved_to.name}", end="\r")


async def main():
    auto = MovieAuto(tasks=1)
    await auto.run("Avatar", progress_hook=progress_callback)


if __name__ == "__main__":
    import asyncio

    asyncio.run(main)
from moviebox_api.v1 import DownloadTracker, MovieAuto


def progress_callback(progress: DownloadTracker):
    percent = (progress.downloaded_size / progress.expected_size) * 100
    print(f"[{percent:.2f}%] Downloading {progress.saved_to.name}", end="\r")


def main():
    auto = MovieAuto(tasks=1)
    auto.run_sync("Avatar", progress_hook=progress_callback)


if __name__ == "__main__":
    main()

Why TV series lack Automagic

This is a deliberate choice by the developers. The current focus is more on implementing new features rather than adding miscellaneous ones. It may be implemented in the future, or you could submit a PR.