mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-13 08:00:47 -08:00
Compare commits
103 Commits
v3.0.0
...
feature/pl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f99ff546d5 | ||
|
|
88b707e060 | ||
|
|
eaedf3268d | ||
|
|
ade0465ea4 | ||
|
|
5e82db4ea8 | ||
|
|
a10e56cb6f | ||
|
|
fbd95e1966 | ||
|
|
d37a441ccf | ||
|
|
cbc1ceccbb | ||
|
|
249a207cad | ||
|
|
c8a42c4920 | ||
|
|
de8b6b7f2f | ||
|
|
54e0942233 | ||
|
|
8ea0c121c2 | ||
|
|
eddaad64e7 | ||
|
|
43be7a52cf | ||
|
|
b689760a25 | ||
|
|
e53246b79b | ||
|
|
b0fc94cdc5 | ||
|
|
449f6c1e59 | ||
|
|
ab4734b79d | ||
|
|
93d0f6a1a5 | ||
|
|
19c75c48b2 | ||
|
|
5341b0a844 | ||
|
|
24e7e6a16b | ||
|
|
4b310e60b8 | ||
|
|
4d50cffd86 | ||
|
|
f6fedf0500 | ||
|
|
7b431450fe | ||
|
|
66b247330b | ||
|
|
c6b8cfc294 | ||
|
|
6895426d67 | ||
|
|
cc69dc35f6 | ||
|
|
ed81f37ae4 | ||
|
|
c6858b00c4 | ||
|
|
a44034a5d4 | ||
|
|
f768518721 | ||
|
|
97f5bb9cb3 | ||
|
|
b09fdbf69b | ||
|
|
071c46cad9 | ||
|
|
5d32503ff9 | ||
|
|
e67532c496 | ||
|
|
819012897d | ||
|
|
c4f78b12a4 | ||
|
|
8aacbcc35b | ||
|
|
5976ab43b2 | ||
|
|
99c67a4bc0 | ||
|
|
34851fd3e4 | ||
|
|
e74b5977bb | ||
|
|
0650f45fba | ||
|
|
0c8f2a70ba | ||
|
|
ce7cd98783 | ||
|
|
ec14c40c77 | ||
|
|
6a6e03c744 | ||
|
|
26de1a0fb4 | ||
|
|
e49fb4898c | ||
|
|
e2407d4948 | ||
|
|
cd16ab50e3 | ||
|
|
b53a7d9b03 | ||
|
|
2b9fdb99b1 | ||
|
|
9c6e1877ed | ||
|
|
73bb77fe46 | ||
|
|
4cdc5bfd34 | ||
|
|
ca491d95a0 | ||
|
|
1003f75db3 | ||
|
|
5821c4ca97 | ||
|
|
de774a58d2 | ||
|
|
ee25cbba10 | ||
|
|
278a771f64 | ||
|
|
0d8c287e2f | ||
|
|
74308dfdc5 | ||
|
|
7ca1b8572e | ||
|
|
54aed9e5a0 | ||
|
|
4511d14e8b | ||
|
|
bff684e8cb | ||
|
|
cfc83450c8 | ||
|
|
04a6a425b7 | ||
|
|
088d232bfd | ||
|
|
03fd8c0bf8 | ||
|
|
17f1744025 | ||
|
|
9a5f3d46be | ||
|
|
66eb854da5 | ||
|
|
ae62adf233 | ||
|
|
55a7c7facf | ||
|
|
2340c34d02 | ||
|
|
40b29ba6e5 | ||
|
|
5dc768f7e8 | ||
|
|
b343bfb645 | ||
|
|
37773265ce | ||
|
|
70ef1bf633 | ||
|
|
bee97acd35 | ||
|
|
fb61fd17f1 | ||
|
|
98fff7d00f | ||
|
|
3cc9ae50b6 | ||
|
|
26f7de172a | ||
|
|
673b6280e4 | ||
|
|
7943dcc3db | ||
|
|
49ee1f9bbd | ||
|
|
fd80149e74 | ||
|
|
7c11616bea | ||
|
|
b9130018ca | ||
|
|
70ade13017 | ||
|
|
071c0daf4f |
15
.github/FUNDING.yml
vendored
15
.github/FUNDING.yml
vendored
@@ -1,15 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: benexl # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: benexl # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
polar: # Replace with a single Polar username
|
||||
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||
thanks_dev: # Replace with a single thanks.dev username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
18
.github/chatmodes/new-command.chatmode.md
vendored
18
.github/chatmodes/new-command.chatmode.md
vendored
@@ -2,29 +2,29 @@
|
||||
description: "Generate a new 'click' command following the project's lazy-loading pattern and service architecture."
|
||||
tools: ['codebase']
|
||||
---
|
||||
# FastAnime: CLI Command Generation Mode
|
||||
# viu: CLI Command Generation Mode
|
||||
|
||||
You are an expert on the `fastanime` CLI structure, which uses `click` and a custom `LazyGroup` for performance. Your task is to generate the boilerplate for a new command.
|
||||
You are an expert on the `viu` CLI structure, which uses `click` and a custom `LazyGroup` for performance. Your task is to generate the boilerplate for a new command.
|
||||
|
||||
**First, ask the user if this is a top-level command (like `fastanime new-cmd`) or a subcommand (like `fastanime anilist new-sub-cmd`).**
|
||||
**First, ask the user if this is a top-level command (like `viu new-cmd`) or a subcommand (like `viu anilist new-sub-cmd`).**
|
||||
|
||||
---
|
||||
|
||||
### If Top-Level Command:
|
||||
|
||||
1. **File Location:** State that the new command file should be created at: `fastanime/cli/commands/{command_name}.py`.
|
||||
1. **File Location:** State that the new command file should be created at: `viu/cli/commands/{command_name}.py`.
|
||||
2. **Boilerplate:** Generate the `click.command()` function.
|
||||
* It **must** accept `config: AppConfig` as the first argument using `@click.pass_obj`.
|
||||
* It **must not** contain business logic. Instead, show how to instantiate a service from `fastanime.cli.service` and call its methods.
|
||||
3. **Registration:** Instruct the user to register the command by adding it to the `commands` dictionary in `fastanime/cli/cli.py`. Provide the exact line to add, like: `"new-cmd": "new_cmd.new_cmd_function"`.
|
||||
* It **must not** contain business logic. Instead, show how to instantiate a service from `viu.cli.service` and call its methods.
|
||||
3. **Registration:** Instruct the user to register the command by adding it to the `commands` dictionary in `viu/cli/cli.py`. Provide the exact line to add, like: `"new-cmd": "new_cmd.new_cmd_function"`.
|
||||
|
||||
---
|
||||
|
||||
### If Subcommand:
|
||||
|
||||
1. **Ask for Parent:** Ask for the parent command group (e.g., `anilist`, `registry`).
|
||||
2. **File Location:** State that the new command file should be created at: `fastanime/cli/commands/{parent_name}/commands/{command_name}.py`.
|
||||
2. **File Location:** State that the new command file should be created at: `viu/cli/commands/{parent_name}/commands/{command_name}.py`.
|
||||
3. **Boilerplate:** Generate the `click.command()` function, similar to the top-level command.
|
||||
4. **Registration:** Instruct the user to register the subcommand in the parent's `cmd.py` file (e.g., `fastanime/cli/commands/anilist/cmd.py`) by adding it to the `lazy_subcommands` dictionary within the `@click.group` decorator.
|
||||
4. **Registration:** Instruct the user to register the subcommand in the parent's `cmd.py` file (e.g., `viu/cli/commands/anilist/cmd.py`) by adding it to the `lazy_subcommands` dictionary within the `@click.group` decorator.
|
||||
|
||||
**Final Instruction:** Remind the user that if the command introduces new logic, it should be encapsulated in a new or existing **Service** class in the `fastanime/cli/service/` directory. The CLI command function should only handle argument parsing and calling the service.
|
||||
**Final Instruction:** Remind the user that if the command introduces new logic, it should be encapsulated in a new or existing **Service** class in the `viu/cli/service/` directory. The CLI command function should only handle argument parsing and calling the service.
|
||||
|
||||
22
.github/chatmodes/new-component.chatmode.md
vendored
22
.github/chatmodes/new-component.chatmode.md
vendored
@@ -2,9 +2,9 @@
|
||||
description: "Scaffold the necessary files and code for a new Player or Selector component, including configuration."
|
||||
tools: ['codebase', 'search']
|
||||
---
|
||||
# FastAnime: New Component Generation Mode
|
||||
# viu: New Component Generation Mode
|
||||
|
||||
You are an expert on `fastanime`'s modular architecture. Your task is to help the developer add a new **Player** or **Selector** component.
|
||||
You are an expert on `viu`'s modular architecture. Your task is to help the developer add a new **Player** or **Selector** component.
|
||||
|
||||
**First, ask the user whether they want to create a 'Player' or a 'Selector'.** Then, follow the appropriate path below.
|
||||
|
||||
@@ -12,13 +12,13 @@ You are an expert on `fastanime`'s modular architecture. Your task is to help th
|
||||
|
||||
### If the user chooses 'Player':
|
||||
|
||||
1. **Scaffold Directory:** Create a directory at `fastanime/libs/player/{player_name}/`.
|
||||
2. **Implement `BasePlayer`:** Create a `player.py` file with a class `NewPlayer` that inherits from `fastanime.libs.player.base.BasePlayer`. Implement the `play` and `play_with_ipc` methods. The `play` method should use `subprocess` to call the player's executable.
|
||||
1. **Scaffold Directory:** Create a directory at `viu/libs/player/{player_name}/`.
|
||||
2. **Implement `BasePlayer`:** Create a `player.py` file with a class `NewPlayer` that inherits from `viu.libs.player.base.BasePlayer`. Implement the `play` and `play_with_ipc` methods. The `play` method should use `subprocess` to call the player's executable.
|
||||
3. **Add Configuration:**
|
||||
* Instruct to create a new Pydantic model `NewPlayerConfig(OtherConfig)` in `fastanime/core/config/model.py`.
|
||||
* Instruct to create a new Pydantic model `NewPlayerConfig(OtherConfig)` in `viu/core/config/model.py`.
|
||||
* Add the new config model to the main `AppConfig`.
|
||||
* Add defaults in `fastanime/core/config/defaults.py` and descriptions in `fastanime/core/config/descriptions.py`.
|
||||
4. **Register Player:** Instruct to modify `fastanime/libs/player/player.py` by:
|
||||
* Add defaults in `viu/core/config/defaults.py` and descriptions in `viu/core/config/descriptions.py`.
|
||||
4. **Register Player:** Instruct to modify `viu/libs/player/player.py` by:
|
||||
* Adding the player name to the `PLAYERS` list.
|
||||
* Adding the instantiation logic to the `PlayerFactory.create` method.
|
||||
|
||||
@@ -26,9 +26,9 @@ You are an expert on `fastanime`'s modular architecture. Your task is to help th
|
||||
|
||||
### If the user chooses 'Selector':
|
||||
|
||||
1. **Scaffold Directory:** Create a directory at `fastanime/libs/selectors/{selector_name}/`.
|
||||
2. **Implement `BaseSelector`:** Create a `selector.py` file with a class `NewSelector` that inherits from `fastanime.libs.selectors.base.BaseSelector`. Implement the `choose`, `confirm`, and `ask` methods.
|
||||
1. **Scaffold Directory:** Create a directory at `viu/libs/selectors/{selector_name}/`.
|
||||
2. **Implement `BaseSelector`:** Create a `selector.py` file with a class `NewSelector` that inherits from `viu.libs.selectors.base.BaseSelector`. Implement the `choose`, `confirm`, and `ask` methods.
|
||||
3. **Add Configuration:** (Follow the same steps as for a Player).
|
||||
4. **Register Selector:**
|
||||
* Instruct to modify `fastanime/libs/selectors/selector.py` by adding the selector name to the `SELECTORS` list and the factory logic to `SelectorFactory.create`.
|
||||
* Instruct to update the `Literal` type hint for the `selector` field in `GeneralConfig` (`fastanime/core/config/model.py`).
|
||||
* Instruct to modify `viu/libs/selectors/selector.py` by adding the selector name to the `SELECTORS` list and the factory logic to `SelectorFactory.create`.
|
||||
* Instruct to update the `Literal` type hint for the `selector` field in `GeneralConfig` (`viu/core/config/model.py`).
|
||||
|
||||
18
.github/chatmodes/new-provider.chatmode.md
vendored
18
.github/chatmodes/new-provider.chatmode.md
vendored
@@ -1,27 +1,27 @@
|
||||
---
|
||||
description: "Scaffold and implement a new anime provider, following all architectural patterns of the fastanime project."
|
||||
description: "Scaffold and implement a new anime provider, following all architectural patterns of the viu project."
|
||||
tools: ['codebase', 'search', 'fetch']
|
||||
---
|
||||
# FastAnime: New Provider Generation Mode
|
||||
# viu: New Provider Generation Mode
|
||||
|
||||
You are an expert on the `fastanime` codebase, specializing in its provider architecture. Your task is to guide the developer in creating a new anime provider. You must strictly adhere to the project's structure and coding conventions.
|
||||
You are an expert on the `viu` codebase, specializing in its provider architecture. Your task is to guide the developer in creating a new anime provider. You must strictly adhere to the project's structure and coding conventions.
|
||||
|
||||
**Your process is as follows:**
|
||||
|
||||
1. **Ask for the Provider's Name:** First, ask the user for the name of the new provider (e.g., `gogoanime`, `crunchyroll`). Use this name (in lowercase) for all subsequent file and directory naming.
|
||||
|
||||
2. **Scaffold the Directory Structure:** Based on the name, state the required directory structure that needs to be created:
|
||||
`fastanime/libs/provider/anime/{provider_name}/`
|
||||
`viu/libs/provider/anime/{provider_name}/`
|
||||
|
||||
3. **Scaffold the Core Files:** Generate the initial code for the following files inside the new directory. Ensure all code is fully type-hinted.
|
||||
|
||||
* **`__init__.py`**: Can be an empty file.
|
||||
* **`types.py`**: Create placeholder `TypedDict` models for the provider's specific API responses (e.g., `GogoAnimeSearchResult`, `GogoAnimeEpisode`).
|
||||
* **`mappers.py`**: Create empty mapping functions that will convert the provider-specific types into the generic types from `fastanime.libs.provider.anime.types`. For example: `map_to_search_results(data: GogoAnimeSearchPage) -> SearchResults:`.
|
||||
* **`provider.py`**: Generate the main provider class. It **MUST** inherit from `fastanime.libs.provider.anime.base.BaseAnimeProvider`. Include stubs for the required abstract methods: `search`, `get`, and `episode_streams`. Remind the user to use `httpx.Client` for requests and to call the mapper functions.
|
||||
* **`mappers.py`**: Create empty mapping functions that will convert the provider-specific types into the generic types from `viu.libs.provider.anime.types`. For example: `map_to_search_results(data: GogoAnimeSearchPage) -> SearchResults:`.
|
||||
* **`provider.py`**: Generate the main provider class. It **MUST** inherit from `viu.libs.provider.anime.base.BaseAnimeProvider`. Include stubs for the required abstract methods: `search`, `get`, and `episode_streams`. Remind the user to use `httpx.Client` for requests and to call the mapper functions.
|
||||
|
||||
4. **Instruct on Registration:** Clearly state the two files that **must** be modified to register the new provider:
|
||||
* **`fastanime/libs/provider/anime/types.py`**: Add the new provider's name to the `ProviderName` enum.
|
||||
* **`fastanime/libs/provider/anime/provider.py`**: Add an entry to the `PROVIDERS_AVAILABLE` dictionary.
|
||||
* **`viu/libs/provider/anime/types.py`**: Add the new provider's name to the `ProviderName` enum.
|
||||
* **`viu/libs/provider/anime/provider.py`**: Add an entry to the `PROVIDERS_AVAILABLE` dictionary.
|
||||
|
||||
5. **Final Guidance:** Remind the developer to add any title normalization rules to `fastanime/assets/normalizer.json` if the provider uses different anime titles than AniList.
|
||||
5. **Final Guidance:** Remind the developer to add any title normalization rules to `viu/assets/normalizer.json` if the provider uses different anime titles than AniList.
|
||||
|
||||
16
.github/chatmodes/plan.chatmode.md
vendored
16
.github/chatmodes/plan.chatmode.md
vendored
@@ -1,11 +1,11 @@
|
||||
---
|
||||
description: "Plan new features or bug fixes with architectural guidance for the fastanime project. Does not write implementation code."
|
||||
description: "Plan new features or bug fixes with architectural guidance for the viu project. Does not write implementation code."
|
||||
tools: ['codebase', 'search', 'githubRepo', 'fetch']
|
||||
model: "gpt-4o"
|
||||
---
|
||||
# FastAnime: Feature & Fix Planner Mode
|
||||
# viu: Feature & Fix Planner Mode
|
||||
|
||||
You are a senior software architect and project planner for the `fastanime` project. You are an expert in its layered architecture (`Core`, `Libs`, `Service`, `CLI`) and its commitment to modular, testable code.
|
||||
You are a senior software architect and project planner for the `viu` project. You are an expert in its layered architecture (`Core`, `Libs`, `Service`, `CLI`) and its commitment to modular, testable code.
|
||||
|
||||
Your primary goal is to help the user break down a feature request or bug report into a clear, actionable implementation plan.
|
||||
|
||||
@@ -33,17 +33,17 @@ Your primary goal is to help the user break down a feature request or bug report
|
||||
|
||||
**2. Architectural Impact Analysis**
|
||||
> This is the most important section. Detail which parts of the codebase will be touched and why.
|
||||
> - **Core Layer (`fastanime/core`):**
|
||||
> - **Core Layer (`viu/core`):**
|
||||
> - *Config (`config/model.py`):* Will a new Pydantic model or field be needed?
|
||||
> - *Utils (`utils/`):* Are any new low-level, reusable functions required?
|
||||
> - *Exceptions (`exceptions.py`):* Does this introduce a new failure case that needs a custom exception?
|
||||
> - **Libs Layer (`fastanime/libs`):**
|
||||
> - **Libs Layer (`viu/libs`):**
|
||||
> - *Media API (`media_api/`):* Does this involve a new call to the AniList API?
|
||||
> - *Provider (`provider/`):* Does this affect how data is scraped?
|
||||
> - *Player/Selector (`player/`, `selectors/`):* Does this change how we interact with external tools?
|
||||
> - **Service Layer (`fastanime/cli/service`):**
|
||||
> - **Service Layer (`viu/cli/service`):**
|
||||
> - Which service will orchestrate this logic? (e.g., `DownloadService`, `PlayerService`). Will a new service be needed?
|
||||
> - **CLI Layer (`fastanime/cli`):**
|
||||
> - **CLI Layer (`viu/cli`):**
|
||||
> - *Commands (`commands/`):* Which `click` command(s) will expose this feature?
|
||||
> - *Interactive UI (`interactive/`):* Which TUI menu(s) need to be added or modified?
|
||||
|
||||
@@ -52,7 +52,7 @@ Your primary goal is to help the user break down a feature request or bug report
|
||||
> 1. [ ] **Config:** Add `new_setting` to `GeneralConfig` in `core/config/model.py`.
|
||||
> 2. [ ] **Core:** Implement `new_util()` in `core/utils/helpers.py`.
|
||||
> 3. [ ] **Service:** Add method `handle_new_feature()` to `MyService`.
|
||||
> 4. [ ] **CLI:** Add `--new-feature` option to the `fastanime anilist search` command.
|
||||
> 4. [ ] **CLI:** Add `--new-feature` option to the `viu anilist search` command.
|
||||
> 5. [ ] **Tests:** Write a unit test for `new_util()` and an integration test for the service method.
|
||||
|
||||
**4. Configuration Changes**
|
||||
|
||||
58
.github/copilot-instructions.md
vendored
58
.github/copilot-instructions.md
vendored
@@ -1,27 +1,27 @@
|
||||
# GitHub Copilot Instructions for the FastAnime Repository
|
||||
# GitHub Copilot Instructions for the viu Repository
|
||||
|
||||
Hello, Copilot! This document provides instructions and context to help you understand the `fastanime` codebase. Following these guidelines will help you generate code that is consistent, maintainable, and aligned with the project's architecture.
|
||||
Hello, Copilot! This document provides instructions and context to help you understand the `viu` codebase. Following these guidelines will help you generate code that is consistent, maintainable, and aligned with the project's architecture.
|
||||
|
||||
## 1. High-Level Project Goal
|
||||
|
||||
`fastanime` is a command-line tool that brings the anime browsing, streaming, and management experience to the terminal. It integrates with metadata providers like AniList and scrapes streaming links from various anime provider websites. The core goals are efficiency, extensibility, and providing a powerful, scriptable user experience.
|
||||
`viu` is a command-line tool that brings the anime browsing, streaming, and management experience to the terminal. It integrates with metadata providers like AniList and scrapes streaming links from various anime provider websites. The core goals are efficiency, extensibility, and providing a powerful, scriptable user experience.
|
||||
|
||||
## 2. Core Architectural Concepts
|
||||
|
||||
The project follows a clean, layered architecture. When generating code, please adhere to this structure.
|
||||
|
||||
#### Layer 1: CLI (`fastanime/cli`)
|
||||
#### Layer 1: CLI (`viu/cli`)
|
||||
* **Purpose:** Handles user interaction, command parsing, and displaying output.
|
||||
* **Key Libraries:** `click` for command structure, `rich` for styled output.
|
||||
* **Interactive Mode:** The interactive TUI is managed by the `Session` object in `fastanime/cli/interactive/session.py`. It's a state machine where each menu is a function that returns the next `State` or an `InternalDirective` (like `BACK` or `EXIT`).
|
||||
* **Interactive Mode:** The interactive TUI is managed by the `Session` object in `viu/cli/interactive/session.py`. It's a state machine where each menu is a function that returns the next `State` or an `InternalDirective` (like `BACK` or `EXIT`).
|
||||
* **Guideline:** **CLI files should not contain complex business logic.** They should parse arguments and delegate tasks to the Service Layer.
|
||||
|
||||
#### Layer 2: Service (`fastanime/cli/service`)
|
||||
#### Layer 2: Service (`viu/cli/service`)
|
||||
* **Purpose:** Contains the core application logic. Services act as orchestrators, connecting the CLI layer with the various library components.
|
||||
* **Examples:** `DownloadService`, `PlayerService`, `MediaRegistryService`, `WatchHistoryService`.
|
||||
* **Guideline:** When adding new functionality (e.g., a new way to manage downloads), it should likely be implemented in a service or an existing service should be extended. Services are the "brains" of the application.
|
||||
|
||||
#### Layer 3: Libraries (`fastanime/libs`)
|
||||
#### Layer 3: Libraries (`viu/libs`)
|
||||
* **Purpose:** A collection of independent, reusable modules with well-defined contracts (Abstract Base Classes).
|
||||
* **`media_api`:** Interfaces with metadata services like AniList. All new metadata clients **must** inherit from `BaseApiClient`.
|
||||
* **`provider`:** Interfaces with anime streaming websites. All new providers **must** inherit from `BaseAnimeProvider`.
|
||||
@@ -29,7 +29,7 @@ The project follows a clean, layered architecture. When generating code, please
|
||||
* **`selectors`:** Wrappers for interactive UI tools like FZF or Rofi. All new selectors **must** inherit from `BaseSelector`.
|
||||
* **Guideline:** Libraries should be self-contained and not depend on the CLI or Service layers. They receive configuration and perform their specific task.
|
||||
|
||||
#### Layer 4: Core (`fastanime/core`)
|
||||
#### Layer 4: Core (`viu/core`)
|
||||
* **Purpose:** Foundational code shared across the entire application.
|
||||
* **`config`:** Pydantic models defining the application's configuration structure. **This is the single source of truth for all settings.**
|
||||
* **`downloader`:** The underlying logic for downloading files (using `yt-dlp` or `httpx`).
|
||||
@@ -39,7 +39,7 @@ The project follows a clean, layered architecture. When generating code, please
|
||||
|
||||
## 3. Key Technologies
|
||||
* **Dependency Management:** `uv` is used for all package management and task running. Refer to `pyproject.toml` for dependencies.
|
||||
* **Configuration:** **Pydantic** is used exclusively. The entire configuration is defined in `fastanime/core/config/model.py`.
|
||||
* **Configuration:** **Pydantic** is used exclusively. The entire configuration is defined in `viu/core/config/model.py`.
|
||||
* **CLI Framework:** `click`. We use a custom `LazyGroup` to load commands on demand for faster startup.
|
||||
* **HTTP Client:** `httpx` is the standard for all network requests.
|
||||
|
||||
@@ -48,37 +48,37 @@ The project follows a clean, layered architecture. When generating code, please
|
||||
Follow these patterns to ensure your contributions fit the existing architecture.
|
||||
|
||||
### How to Add a New Provider
|
||||
1. **Create Directory:** Add a new folder in `fastanime/libs/provider/anime/newprovider/`.
|
||||
1. **Create Directory:** Add a new folder in `viu/libs/provider/anime/newprovider/`.
|
||||
2. **Implement `BaseAnimeProvider`:** In `provider.py`, create a class `NewProvider` that inherits from `BaseAnimeProvider` and implement the `search`, `get`, and `episode_streams` methods.
|
||||
3. **Create Mappers:** In `mappers.py`, write functions to convert the provider's API/HTML data into the generic Pydantic models from `fastanime/libs/provider/anime/types.py` (e.g., `SearchResult`, `Anime`, `Server`).
|
||||
3. **Create Mappers:** In `mappers.py`, write functions to convert the provider's API/HTML data into the generic Pydantic models from `viu/libs/provider/anime/types.py` (e.g., `SearchResult`, `Anime`, `Server`).
|
||||
4. **Register Provider:**
|
||||
* Add the provider's name to the `ProviderName` enum in `fastanime/libs/provider/anime/types.py`.
|
||||
* Add it to the `PROVIDERS_AVAILABLE` dictionary in `fastanime/libs/provider/anime/provider.py`.
|
||||
* Add the provider's name to the `ProviderName` enum in `viu/libs/provider/anime/types.py`.
|
||||
* Add it to the `PROVIDERS_AVAILABLE` dictionary in `viu/libs/provider/anime/provider.py`.
|
||||
|
||||
### How to Add a New Player
|
||||
1. **Create Directory:** Add a new folder in `fastanime/libs/player/newplayer/`.
|
||||
1. **Create Directory:** Add a new folder in `viu/libs/player/newplayer/`.
|
||||
2. **Implement `BasePlayer`:** In `player.py`, create a class `NewPlayer` that inherits from `BasePlayer` and implement the `play` method. It should call the player's executable via `subprocess`.
|
||||
3. **Add Configuration:** If the player has settings, add a `NewPlayerConfig` Pydantic model in `fastanime/core/config/model.py`, and add it to the main `AppConfig`. Also add defaults and descriptions.
|
||||
4. **Register Player:** Add the player's name to the `PLAYERS` list and the factory logic in `fastanime/libs/player/player.py`.
|
||||
3. **Add Configuration:** If the player has settings, add a `NewPlayerConfig` Pydantic model in `viu/core/config/model.py`, and add it to the main `AppConfig`. Also add defaults and descriptions.
|
||||
4. **Register Player:** Add the player's name to the `PLAYERS` list and the factory logic in `viu/libs/player/player.py`.
|
||||
|
||||
### How to Add a New Selector
|
||||
1. **Create Directory:** Add a new folder in `fastanime/libs/selectors/newselector/`.
|
||||
1. **Create Directory:** Add a new folder in `viu/libs/selectors/newselector/`.
|
||||
2. **Implement `BaseSelector`:** In `selector.py`, create a class `NewSelector` that inherits from `BaseSelector` and implement `choose`, `confirm`, and `ask`.
|
||||
3. **Add Configuration:** If needed, add a `NewSelectorConfig` to `fastanime/core/config/model.py`.
|
||||
4. **Register Selector:** Add the selector's name to the `SELECTORS` list and the factory logic in `fastanime/libs/selectors/selector.py`. Update the `Literal` type hint for `selector` in `GeneralConfig`.
|
||||
3. **Add Configuration:** If needed, add a `NewSelectorConfig` to `viu/core/config/model.py`.
|
||||
4. **Register Selector:** Add the selector's name to the `SELECTORS` list and the factory logic in `viu/libs/selectors/selector.py`. Update the `Literal` type hint for `selector` in `GeneralConfig`.
|
||||
|
||||
### How to Add a New CLI Command
|
||||
* **Top-Level Command (`fastanime my-command`):**
|
||||
1. Create `fastanime/cli/commands/my_command.py` with your `click.command()`.
|
||||
2. Register it in the `commands` dictionary in `fastanime/cli/cli.py`.
|
||||
* **Subcommand (`fastanime anilist my-subcommand`):**
|
||||
1. Create `fastanime/cli/commands/anilist/commands/my_subcommand.py`.
|
||||
2. Register it in the `lazy_subcommands` dictionary of the parent `click.group()` (e.g., in `fastanime/cli/commands/anilist/cmd.py`).
|
||||
* **Top-Level Command (`viu my-command`):**
|
||||
1. Create `viu/cli/commands/my_command.py` with your `click.command()`.
|
||||
2. Register it in the `commands` dictionary in `viu/cli/cli.py`.
|
||||
* **Subcommand (`viu anilist my-subcommand`):**
|
||||
1. Create `viu/cli/commands/anilist/commands/my_subcommand.py`.
|
||||
2. Register it in the `lazy_subcommands` dictionary of the parent `click.group()` (e.g., in `viu/cli/commands/anilist/cmd.py`).
|
||||
|
||||
### How to Add a New Configuration Option
|
||||
1. **Add to Model:** Add the field to the appropriate Pydantic model in `fastanime/core/config/model.py`.
|
||||
2. **Add Default:** Add a default value in `fastanime/core/config/defaults.py`.
|
||||
3. **Add Description:** Add a user-friendly description in `fastanime/core/config/descriptions.py`.
|
||||
1. **Add to Model:** Add the field to the appropriate Pydantic model in `viu/core/config/model.py`.
|
||||
2. **Add Default:** Add a default value in `viu/core/config/defaults.py`.
|
||||
3. **Add Description:** Add a user-friendly description in `viu/core/config/descriptions.py`.
|
||||
4. The config loader and CLI option generation will handle the rest automatically.
|
||||
|
||||
## 5. Code Style and Conventions
|
||||
@@ -91,7 +91,7 @@ Follow these patterns to ensure your contributions fit the existing architecture
|
||||
|
||||
* ✅ **DO** use the abstract base classes (`BaseProvider`, `BasePlayer`, etc.) as contracts.
|
||||
* ✅ **DO** place business logic in the `service` layer.
|
||||
* ✅ **DO** use the Pydantic models in `fastanime/core/config/model.py` as the single source of truth for configuration.
|
||||
* ✅ **DO** use the Pydantic models in `viu/core/config/model.py` as the single source of truth for configuration.
|
||||
* ✅ **DO** use the `Context` object in interactive menus to access services and configuration.
|
||||
|
||||
* ❌ **DON'T** hardcode configuration values. Access them via the `config` object.
|
||||
|
||||
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -20,13 +20,13 @@ jobs:
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- name: Build fastanime
|
||||
- name: Build viu
|
||||
run: uv build
|
||||
|
||||
- name: Archive production artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: fastanime_debug_build
|
||||
name: viu_debug_build
|
||||
path: |
|
||||
dist
|
||||
|
||||
|
||||
11
.github/workflows/publish.yml
vendored
11
.github/workflows/publish.yml
vendored
@@ -1,12 +1,3 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
# GitHub recommends pinning actions to a commit SHA.
|
||||
# To get a newer version, you will need to update the SHA.
|
||||
# You can also reference a tag or branch, but the action may change without warning.
|
||||
|
||||
name: Upload Python Package
|
||||
|
||||
on:
|
||||
@@ -32,7 +23,7 @@ jobs:
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- name: Build fastanime
|
||||
- name: Build viu
|
||||
run: uv build
|
||||
|
||||
- name: Upload distributions
|
||||
|
||||
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10", "3.11"] # List the Python versions you want to test
|
||||
python-version: ["3.11", "3.12"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -22,6 +22,11 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install dbus-python build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install libdbus-1-dev libglib2.0-dev
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v3
|
||||
with:
|
||||
|
||||
1
.repomixignore
Normal file
1
.repomixignore
Normal file
@@ -0,0 +1 @@
|
||||
**/generated/**/*
|
||||
@@ -1,29 +1,29 @@
|
||||
# Contributing to FastAnime
|
||||
# Contributing to Viu
|
||||
|
||||
First off, thank you for considering contributing to FastAnime! We welcome any help, whether it's reporting a bug, proposing a feature, or writing code. This document will guide you through the process.
|
||||
First off, thank you for considering contributing to Viu! We welcome any help, whether it's reporting a bug, proposing a feature, or writing code. This document will guide you through the process.
|
||||
|
||||
## How Can I Contribute?
|
||||
|
||||
There are many ways to contribute to the FastAnime project:
|
||||
There are many ways to contribute to the Viu project:
|
||||
|
||||
* **Reporting Bugs:** If you find a bug, please create an issue in our [issue tracker](https://github.com/Benexl/FastAnime/issues).
|
||||
* **Reporting Bugs:** If you find a bug, please create an issue in our [issue tracker](https://github.com/Benexl/Viu/issues).
|
||||
* **Suggesting Enhancements:** Have an idea for a new feature or an improvement to an existing one? We'd love to hear it.
|
||||
* **Writing Code:** Help us fix bugs or implement new features.
|
||||
* **Improving Documentation:** Enhance our README, add examples, or clarify our contribution guidelines.
|
||||
* **Adding a Provider, Player, or Selector:** Extend FastAnime's capabilities by integrating new tools and services.
|
||||
* **Adding a Provider, Player, or Selector:** Extend Viu's capabilities by integrating new tools and services.
|
||||
|
||||
## Contribution Workflow
|
||||
|
||||
We follow the standard GitHub Fork & Pull Request workflow.
|
||||
|
||||
1. **Create an Issue:** Before starting work on a new feature or a significant bug fix, please [create an issue](https://github.com/Benexl/FastAnime/issues/new/choose) to discuss your idea. This allows us to give feedback and prevent duplicate work. For small bugs or documentation typos, you can skip this step.
|
||||
1. **Create an Issue:** Before starting work on a new feature or a significant bug fix, please [create an issue](https://github.com/Benexl/Viu/issues/new/choose) to discuss your idea. This allows us to give feedback and prevent duplicate work. For small bugs or documentation typos, you can skip this step.
|
||||
|
||||
2. **Fork the Repository:** Create your own fork of the FastAnime repository.
|
||||
2. **Fork the Repository:** Create your own fork of the Viu repository.
|
||||
|
||||
3. **Clone Your Fork:**
|
||||
```bash
|
||||
git clone https://github.com/YOUR_USERNAME/FastAnime.git
|
||||
cd FastAnime
|
||||
git clone https://github.com/YOUR_USERNAME/Viu.git
|
||||
cd Viu
|
||||
```
|
||||
|
||||
4. **Create a Branch:** Create a new branch for your changes. Use a descriptive name.
|
||||
@@ -64,7 +64,7 @@ We follow the standard GitHub Fork & Pull Request workflow.
|
||||
git push origin feat/my-new-feature
|
||||
```
|
||||
|
||||
9. **Submit a Pull Request:** Open a pull request from your branch to the `master` branch of the main FastAnime repository. Provide a clear title and description of your changes.
|
||||
9. **Submit a Pull Request:** Open a pull request from your branch to the `master` branch of the main Viu repository. Provide a clear title and description of your changes.
|
||||
|
||||
## Setting Up Your Development Environment
|
||||
|
||||
@@ -111,7 +111,7 @@ To maintain code quality and consistency, please adhere to the following guideli
|
||||
* **Modularity and Architecture:**
|
||||
* **Services:** Business logic is organized into services (e.g., `PlayerService`, `DownloadService`).
|
||||
* **Factories:** Use factory patterns (`create_provider`, `create_selector`) for creating instances of different implementations.
|
||||
* **Configuration:** All configuration is managed through Pydantic models in `fastanime/core/config/model.py`. When adding new config options, update the model, defaults, and descriptions.
|
||||
* **Configuration:** All configuration is managed through Pydantic models in `viu/core/config/model.py`. When adding new config options, update the model, defaults, and descriptions.
|
||||
* **Commit Messages:** Follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard.
|
||||
* **Testing:** New features should be accompanied by tests. Bug fixes should ideally include a regression test.
|
||||
|
||||
@@ -119,25 +119,25 @@ To maintain code quality and consistency, please adhere to the following guideli
|
||||
|
||||
Adding a new anime provider is a great way to contribute. Here are the steps:
|
||||
|
||||
1. **Create a New Provider Directory:** Inside `fastanime/libs/provider/anime/`, create a new directory with the provider's name (e.g., `fastanime/libs/provider/anime/newprovider/`).
|
||||
1. **Create a New Provider Directory:** Inside `viu/libs/provider/anime/`, create a new directory with the provider's name (e.g., `viu/libs/provider/anime/newprovider/`).
|
||||
|
||||
2. **Implement the Provider:**
|
||||
* Create a `provider.py` file.
|
||||
* Define a class (e.g., `NewProviderApi`) that inherits from `BaseAnimeProvider`.
|
||||
* Implement the abstract methods: `search`, `get`, and `episode_streams`.
|
||||
* Create `mappers.py` to convert the provider's data structures into the generic types defined in `fastanime/libs/provider/anime/types.py`.
|
||||
* Create `mappers.py` to convert the provider's data structures into the generic types defined in `viu/libs/provider/anime/types.py`.
|
||||
* Create `types.py` for any provider-specific data structures you need.
|
||||
* If the provider requires complex scraping, place extractor logic in an `extractors/` subdirectory.
|
||||
|
||||
3. **Register the Provider:**
|
||||
* Add your new provider to the `ProviderName` enum in `fastanime/libs/provider/anime/types.py`.
|
||||
* Register it in the `PROVIDERS_AVAILABLE` dictionary in `fastanime/libs/provider/anime/provider.py`.
|
||||
* Add your new provider to the `ProviderName` enum in `viu/libs/provider/anime/types.py`.
|
||||
* Register it in the `PROVIDERS_AVAILABLE` dictionary in `viu/libs/provider/anime/provider.py`.
|
||||
|
||||
4. **Add Normalization Rules (Optional):** If the provider uses different anime titles than AniList, add mappings to `fastanime/assets/normalizer.json`.
|
||||
4. **Add Normalization Rules (Optional):** If the provider uses different anime titles than AniList, add mappings to `viu/assets/normalizer.json`.
|
||||
|
||||
## How to Add a New Player
|
||||
|
||||
1. **Create a New Player Directory:** Inside `fastanime/libs/player/`, create a directory for your player (e.g., `fastanime/libs/player/myplayer/`).
|
||||
1. **Create a New Player Directory:** Inside `viu/libs/player/`, create a directory for your player (e.g., `viu/libs/player/myplayer/`).
|
||||
|
||||
2. **Implement the Player Class:**
|
||||
* In `myplayer/player.py`, create a class (e.g., `MyPlayer`) that inherits from `BasePlayer`.
|
||||
@@ -145,17 +145,17 @@ Adding a new anime provider is a great way to contribute. Here are the steps:
|
||||
* The `play` method should handle launching the player as a subprocess and return a `PlayerResult`.
|
||||
|
||||
3. **Add Configuration (if needed):**
|
||||
* If your player has configurable options, add a new Pydantic model (e.g., `MyPlayerConfig`) in `fastanime/core/config/model.py`. It should inherit from `OtherConfig`.
|
||||
* If your player has configurable options, add a new Pydantic model (e.g., `MyPlayerConfig`) in `viu/core/config/model.py`. It should inherit from `OtherConfig`.
|
||||
* Add this new config model as a field in the main `AppConfig` model.
|
||||
* Add default values in `defaults.py` and descriptions in `descriptions.py`.
|
||||
|
||||
4. **Register the Player:**
|
||||
* Add your player's name to the `PLAYERS` list in `fastanime/libs/player/player.py`.
|
||||
* Add your player's name to the `PLAYERS` list in `viu/libs/player/player.py`.
|
||||
* Add the logic to instantiate your player class within the `PlayerFactory.create` method.
|
||||
|
||||
## How to Add a New Selector
|
||||
|
||||
1. **Create a New Selector Directory:** Inside `fastanime/libs/selectors/`, create a new directory (e.g., `fastanime/libs/selectors/myselector/`).
|
||||
1. **Create a New Selector Directory:** Inside `viu/libs/selectors/`, create a new directory (e.g., `viu/libs/selectors/myselector/`).
|
||||
|
||||
2. **Implement the Selector Class:**
|
||||
* In `myselector/selector.py`, create a class (e.g., `MySelector`) that inherits from `BaseSelector`.
|
||||
@@ -165,19 +165,19 @@ Adding a new anime provider is a great way to contribute. Here are the steps:
|
||||
3. **Add Configuration (if needed):** Follow the same configuration steps as for adding a new player.
|
||||
|
||||
4. **Register the Selector:**
|
||||
* Add your selector's name to the `SELECTORS` list in `fastanime/libs/selectors/selector.py`.
|
||||
* Add your selector's name to the `SELECTORS` list in `viu/libs/selectors/selector.py`.
|
||||
* Add the instantiation logic to the `SelectorFactory.create` method.
|
||||
* Update the `Literal` type hint for the `selector` field in `GeneralConfig` (`fastanime/core/config/model.py`).
|
||||
* Update the `Literal` type hint for the `selector` field in `GeneralConfig` (`viu/core/config/model.py`).
|
||||
|
||||
## How to Add a New CLI Command or Service
|
||||
|
||||
Our CLI uses `click` and a `LazyGroup` class to load commands on demand.
|
||||
|
||||
### Adding a Top-Level Command (e.g., `fastanime my-command`)
|
||||
### Adding a Top-Level Command (e.g., `viu my-command`)
|
||||
|
||||
1. **Create the Command File:** Create a new Python file in `fastanime/cli/commands/` (e.g., `my_command.py`). This file should contain your `click.command()` function.
|
||||
1. **Create the Command File:** Create a new Python file in `viu/cli/commands/` (e.g., `my_command.py`). This file should contain your `click.command()` function.
|
||||
|
||||
2. **Register the Command:** In `fastanime/cli/cli.py`, add your command to the `commands` dictionary.
|
||||
2. **Register the Command:** In `viu/cli/cli.py`, add your command to the `commands` dictionary.
|
||||
```python
|
||||
commands = {
|
||||
# ... existing commands
|
||||
@@ -185,11 +185,11 @@ Our CLI uses `click` and a `LazyGroup` class to load commands on demand.
|
||||
}
|
||||
```
|
||||
|
||||
### Adding a Subcommand (e.g., `fastanime anilist my-subcommand`)
|
||||
### Adding a Subcommand (e.g., `viu anilist my-subcommand`)
|
||||
|
||||
1. **Create the Command File:** Place your new command file inside the appropriate subdirectory, for example, `fastanime/cli/commands/anilist/commands/my_subcommand.py`.
|
||||
1. **Create the Command File:** Place your new command file inside the appropriate subdirectory, for example, `viu/cli/commands/anilist/commands/my_subcommand.py`.
|
||||
|
||||
2. **Register the Subcommand:** In the parent command's entry point file (e.g., `fastanime/cli/commands/anilist/cmd.py`), add your subcommand to the `commands` dictionary within the `LazyGroup`.
|
||||
2. **Register the Subcommand:** In the parent command's entry point file (e.g., `viu/cli/commands/anilist/cmd.py`), add your subcommand to the `commands` dictionary within the `LazyGroup`.
|
||||
```python
|
||||
@click.group(
|
||||
cls=LazyGroup,
|
||||
@@ -202,7 +202,7 @@ Our CLI uses `click` and a `LazyGroup` class to load commands on demand.
|
||||
```
|
||||
|
||||
### Creating a Service
|
||||
If your command involves complex logic, consider creating a service in `fastanime/cli/service/` to keep the business logic separate from the command-line interface. This service can then be instantiated and used within your `click` command function. This follows the existing pattern for services like `DownloadService` and `PlayerService`.
|
||||
If your command involves complex logic, consider creating a service in `viu/cli/service/` to keep the business logic separate from the command-line interface. This service can then be instantiated and used within your `click` command function. This follows the existing pattern for services like `DownloadService` and `PlayerService`.
|
||||
|
||||
---
|
||||
Thank you for contributing to FastAnime
|
||||
Thank you for contributing to Viu
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
<h2>This project: fastanime</h2>
|
||||
<h2>This project: viu</h2>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
319
PLUGINS.md
Normal file
319
PLUGINS.md
Normal file
@@ -0,0 +1,319 @@
|
||||
# Viu Plugin Development Guide
|
||||
|
||||
This guide explains how to create plugins for viu, the terminal-based anime streaming tool.
|
||||
|
||||
## Overview
|
||||
|
||||
Viu supports four types of plugins:
|
||||
|
||||
- **Providers**: Add support for new anime streaming websites
|
||||
- **Players**: Add support for new media players
|
||||
- **Selectors**: Add support for new interactive selection tools
|
||||
- **Commands**: Add new CLI commands to viu
|
||||
|
||||
## Plugin Structure
|
||||
|
||||
Every plugin must be a Git repository with the following structure:
|
||||
|
||||
```
|
||||
your-plugin-repo/
|
||||
├── plugin.info.toml # Plugin metadata (required)
|
||||
├── your_module.py # Your plugin implementation
|
||||
├── config.toml # Default configuration (optional)
|
||||
├── requirements.txt # Dependencies (optional)
|
||||
├── utils.py # Additional modules (optional)
|
||||
├── helpers/ # Subdirectories supported (optional)
|
||||
│ ├── __init__.py
|
||||
│ └── parser.py
|
||||
└── README.md # Documentation (recommended)
|
||||
```
|
||||
|
||||
### Multi-File Plugins
|
||||
|
||||
Viu supports plugins with multiple Python files. You can organize your plugin code across multiple modules and import between them normally:
|
||||
|
||||
```python
|
||||
# In your main plugin file
|
||||
from utils import helper_function
|
||||
from helpers.parser import ResponseParser
|
||||
|
||||
class MyProvider(BaseAnimeProvider):
|
||||
def __init__(self, client, **config):
|
||||
self.parser = ResponseParser()
|
||||
# ... rest of implementation
|
||||
```
|
||||
|
||||
The plugin system automatically adds your plugin directory to Python's import path during loading, so relative imports work as expected.
|
||||
|
||||
### Plugin Manifest (`plugin.info.toml`)
|
||||
|
||||
Every plugin repository must contain a `plugin.info.toml` file at its root:
|
||||
|
||||
```toml
|
||||
[plugin]
|
||||
name = "My Awesome Plugin"
|
||||
version = "1.0.0"
|
||||
description = "Adds support for Example Anime Site"
|
||||
author = "Your Name"
|
||||
homepage = "https://github.com/yourname/viu-example-plugin"
|
||||
requires_python = ">=3.11"
|
||||
|
||||
[components]
|
||||
# Specify which components your plugin provides
|
||||
provider = "example_provider:ExampleProvider" # format: module:class
|
||||
# player = "my_player:MyPlayer" # (if providing a player)
|
||||
# selector = "my_selector:MySelector" # (if providing a selector)
|
||||
# command = "my_command:my_command_func" # (if providing a command)
|
||||
```
|
||||
|
||||
## Provider Plugins
|
||||
|
||||
Provider plugins add support for new anime streaming websites.
|
||||
|
||||
### Requirements
|
||||
|
||||
Your provider class must inherit from `BaseAnimeProvider` and implement:
|
||||
|
||||
- `search(query: str) -> SearchResults`
|
||||
- `get(anime_id: str) -> Anime`
|
||||
- `episode_streams(anime_id: str, episode: str) -> List[Server]`
|
||||
|
||||
### Example Provider Plugin
|
||||
|
||||
**plugin.info.toml:**
|
||||
|
||||
```toml
|
||||
[plugin]
|
||||
name = "Example Anime Provider"
|
||||
version = "1.0.0"
|
||||
description = "Adds support for example.anime.site"
|
||||
|
||||
[components]
|
||||
provider = "example_provider:ExampleProvider"
|
||||
```
|
||||
|
||||
**example_provider.py:**
|
||||
|
||||
```python
|
||||
from typing import List
|
||||
from httpx import Client
|
||||
|
||||
# These imports work because viu adds the plugin path to sys.path
|
||||
from viu_media.libs.provider.anime.base import BaseAnimeProvider
|
||||
from viu_media.libs.provider.anime.types import SearchResults, Anime, Server
|
||||
|
||||
class ExampleProvider(BaseAnimeProvider):
|
||||
HEADERS = {
|
||||
"Referer": "https://example.anime.site/",
|
||||
}
|
||||
|
||||
def __init__(self, client: Client, **config):
|
||||
self.client = client
|
||||
# Access plugin configuration
|
||||
self.timeout = config.get("timeout", 30)
|
||||
self.preferred_quality = config.get("preferred_quality", "720p")
|
||||
|
||||
def search(self, query: str) -> SearchResults:
|
||||
# Implement search logic
|
||||
response = self.client.get(f"https://example.anime.site/search?q={query}")
|
||||
# Parse response and return SearchResults
|
||||
return SearchResults(...)
|
||||
|
||||
def get(self, anime_id: str) -> Anime:
|
||||
# Implement anime details fetching
|
||||
response = self.client.get(f"https://example.anime.site/anime/{anime_id}")
|
||||
# Parse response and return Anime
|
||||
return Anime(...)
|
||||
|
||||
def episode_streams(self, anime_id: str, episode: str) -> List[Server]:
|
||||
# Implement stream URL extraction
|
||||
response = self.client.get(f"https://example.anime.site/watch/{anime_id}/{episode}")
|
||||
# Parse response and return list of Server objects
|
||||
return [Server(...)]
|
||||
```
|
||||
|
||||
## Player Plugins
|
||||
|
||||
Player plugins add support for new media players.
|
||||
|
||||
### Requirements
|
||||
|
||||
Your player class must inherit from `BasePlayer` and implement:
|
||||
|
||||
- `play(media_url: str, **kwargs) -> None`
|
||||
|
||||
### Example Player Plugin
|
||||
|
||||
**plugin.info.toml:**
|
||||
|
||||
```toml
|
||||
[plugin]
|
||||
name = "Custom Player"
|
||||
version = "1.0.0"
|
||||
description = "Adds support for my custom media player"
|
||||
|
||||
[components]
|
||||
player = "custom_player:CustomPlayer"
|
||||
```
|
||||
|
||||
**custom_player.py:**
|
||||
|
||||
```python
|
||||
import subprocess
|
||||
from viu_media.libs.player.base import BasePlayer
|
||||
|
||||
class CustomPlayer(BasePlayer):
|
||||
def __init__(self, **config):
|
||||
self.executable = config.get("executable", "my-player")
|
||||
self.extra_args = config.get("extra_args", [])
|
||||
|
||||
def play(self, media_url: str, **kwargs) -> None:
|
||||
cmd = [self.executable] + self.extra_args + [media_url]
|
||||
subprocess.run(cmd)
|
||||
```
|
||||
|
||||
## Selector Plugins
|
||||
|
||||
Selector plugins add support for new interactive selection tools.
|
||||
|
||||
### Requirements
|
||||
|
||||
Your selector class must inherit from `BaseSelector` and implement:
|
||||
|
||||
- `choose(choices: List[str], **kwargs) -> str`
|
||||
- `confirm(message: str, **kwargs) -> bool`
|
||||
- `ask(message: str, **kwargs) -> str`
|
||||
|
||||
## Command Plugins
|
||||
|
||||
Command plugins add new CLI commands to viu.
|
||||
|
||||
### Example Command Plugin
|
||||
|
||||
**plugin.info.toml:**
|
||||
|
||||
```toml
|
||||
[plugin]
|
||||
name = "My Command"
|
||||
version = "1.0.0"
|
||||
description = "Adds a custom command to viu"
|
||||
|
||||
[components]
|
||||
command = "my_command:my_command"
|
||||
```
|
||||
|
||||
**my_command.py:**
|
||||
|
||||
```python
|
||||
import click
|
||||
|
||||
@click.command()
|
||||
@click.argument("arg1")
|
||||
def my_command(arg1: str):
|
||||
"""My custom command description."""
|
||||
click.echo(f"Hello from plugin command with arg: {arg1}")
|
||||
```
|
||||
|
||||
## Plugin Configuration
|
||||
|
||||
Plugins can include a default configuration file (`config.toml`) in their repository root. When a plugin is installed, this default configuration is automatically copied to the user's `~/.config/viu/plugins.config.toml` file.
|
||||
|
||||
**Example `config.toml` in plugin repository:**
|
||||
|
||||
```toml
|
||||
# Default configuration for My Plugin
|
||||
[my-plugin-name]
|
||||
timeout = 30
|
||||
preferred_quality = "720p"
|
||||
custom_option = "default_value"
|
||||
```
|
||||
|
||||
**After installation, users can customize by editing `~/.config/viu/plugins.config.toml`:**
|
||||
|
||||
```toml
|
||||
[my-plugin-name]
|
||||
timeout = 60 # Customized value
|
||||
preferred_quality = "1080p" # Customized value
|
||||
custom_option = "my_value" # Customized value
|
||||
```
|
||||
|
||||
Access this configuration in your plugin constructor via the `**config` parameter.
|
||||
|
||||
## Installation and Usage
|
||||
|
||||
### For Plugin Developers
|
||||
|
||||
1. Create your plugin repository following the structure above
|
||||
2. Test your plugin locally
|
||||
3. Publish your repository on GitHub/GitLab
|
||||
4. Share the installation command with users
|
||||
|
||||
### For Users
|
||||
|
||||
Install a plugin:
|
||||
|
||||
```bash
|
||||
viu plugin add --type provider myplugin github:user/viu-myplugin
|
||||
```
|
||||
|
||||
Configure the plugin by editing `~/.config/viu/plugins.config.toml`:
|
||||
|
||||
```toml
|
||||
[myplugin]
|
||||
option1 = "value1"
|
||||
option2 = "value2"
|
||||
```
|
||||
|
||||
Use the plugin:
|
||||
|
||||
```bash
|
||||
viu --provider myplugin search "anime name"
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
If your plugin requires additional Python packages, include a `requirements.txt` file in your repository root. Users will need to install these manually:
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Error Handling**: Implement proper error handling and logging
|
||||
2. **Configuration**: Make your plugin configurable through the config system
|
||||
3. **Documentation**: Include a README.md with usage instructions
|
||||
4. **Testing**: Test your plugin thoroughly before publishing
|
||||
5. **Versioning**: Use semantic versioning for your plugin releases
|
||||
6. **Compatibility**: Specify minimum Python version requirements
|
||||
|
||||
## Plugin Management Commands
|
||||
|
||||
```bash
|
||||
# Install a plugin
|
||||
viu plugin add --type provider myplugin github:user/viu-myplugin
|
||||
|
||||
# List installed plugins
|
||||
viu plugin list
|
||||
viu plugin list --type provider
|
||||
|
||||
# Update a plugin
|
||||
viu plugin update --type provider myplugin
|
||||
|
||||
# Remove a plugin
|
||||
viu plugin remove --type provider myplugin
|
||||
```
|
||||
|
||||
## Example Plugins
|
||||
|
||||
Check out these example plugin repositories:
|
||||
|
||||
- [Example Provider Plugin](https://github.com/example/viu-example-provider)
|
||||
- [Example Player Plugin](https://github.com/example/viu-example-player)
|
||||
|
||||
## Support
|
||||
|
||||
For plugin development support:
|
||||
|
||||
- Open an issue in the main viu repository
|
||||
- Join the Discord server: https://discord.gg/C4rhMA4mmK
|
||||
435
README.md
435
README.md
@@ -1,5 +1,5 @@
|
||||
<p align="center">
|
||||
<h1 align="center">FastAnime</h1>
|
||||
<h1 align="center">Viu</h1>
|
||||
</p>
|
||||
<p align="center">
|
||||
<sup>
|
||||
@@ -8,354 +8,307 @@
|
||||
</p>
|
||||
<div align="center">
|
||||
|
||||
 
|
||||

|
||||

|
||||

|
||||

|
||||
[](https://pypi.org/project/viu-media/)
|
||||
[](https://pypi.org/project/viu-media/)
|
||||
[](https://github.com/Benexl/Viu/actions)
|
||||
[](https://discord.gg/HBEmAwvbHV)
|
||||
[](https://github.com/Benexl/Viu/issues)
|
||||
[](https://github.com/Benexl/Viu/blob/master/LICENSE)
|
||||
|
||||
</div>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://discord.gg/HBEmAwvbHV">
|
||||
<img src="https://invidget.switchblade.xyz/C4rhMA4mmK">
|
||||
<img src="https://invidget.switchblade.xyz/C4rhMA4mmK" alt="Discord Server Invite">
|
||||
</a>
|
||||
</p>
|
||||
|
||||

|
||||
|
||||
<details>
|
||||
<summary>
|
||||
<b>Screenshots</b>
|
||||
</summary>
|
||||
<b>Media Results Menu:</b>
|
||||
<img width="1346" height="710" alt="image" src="https://github.com/user-attachments/assets/c56da5d2-d55d-445c-9ad7-4e007e986d5b" />
|
||||
<b>Episodes Menu with Preview:</b>
|
||||
<img width="1346" height="710" alt="image" src="https://github.com/user-attachments/assets/2294f621-8549-4b1c-9e28-d851b2585037" />
|
||||
## Core Features
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
<b>Riced Preview Examples</b>
|
||||
</summary>
|
||||
|
||||
**Anilist Results Menu (FZF):**
|
||||

|
||||
|
||||
**Episodes Menu with Preview (FZF):**
|
||||

|
||||
|
||||
**No Image Preview Mode:**
|
||||

|
||||
|
||||
**Desktop Notifications + Episodes Menu:**
|
||||

|
||||
|
||||
</details>
|
||||
* 📺 **Interactive TUI:** Browse, search, and manage your AniList library in a rich terminal interface powered by `fzf`, `rofi`, or a built-in selector.
|
||||
* ⚡ **Powerful Search:** Filter the entire AniList database with over 20 different criteria, including genres, tags, year, status, and score.
|
||||
* 💾 **Local Registry:** Maintain a fast, local database of your anime for offline access, detailed stats, and robust data management.
|
||||
* ⚙️ **Background Downloader:** Queue episodes for download and let a persistent background worker handle the rest.
|
||||
* 📜 **Scriptable CLI:** Automate streaming and downloading with powerful, non-interactive commands perfect for scripting.
|
||||
* 🔧 **Highly Customizable:** Tailor every aspect—from UI colors and providers to playback behavior—via a simple, well-documented configuration file.
|
||||
* 🔌 **Extensible Architecture:** Easily add new providers, media players, and UI selectors to fit your workflow.
|
||||
|
||||
## Installation
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
Viu runs on any platform with Python 3.10+, including Windows, macOS, Linux, and Android (via Termux).
|
||||
|
||||
The app runs wherever Python 3.10+ is available. On Android, you can use [Termux](https://github.com/termux/termux-app). For installation help, join our [Discord](https://discord.gg/HBEmAwvbHV).
|
||||
### Prerequisites
|
||||
|
||||
### Installation on NixOS
|
||||
For the best experience, please install these external tools:
|
||||
|
||||

|
||||
|
||||
```bash
|
||||
nix profile install github:Benexl/fastanime
|
||||
```
|
||||
|
||||
### Installation on Arch Linux
|
||||
|
||||

|
||||
|
||||
Install from the AUR using an AUR helper like `yay` or `paru`.
|
||||
|
||||
```bash
|
||||
# Stable version (recommended)
|
||||
yay -S fastanime
|
||||
|
||||
# Git version (latest commit)
|
||||
yay -S fastanime-git
|
||||
```
|
||||
* **Required for Streaming:**
|
||||
* [**mpv**](https://mpv.io/installation/) - The primary and recommended media player.
|
||||
* **Recommended for UI & Previews:**
|
||||
* [**fzf**](https://github.com/junegunn/fzf) - For the best fuzzy-finder interface.
|
||||
* [**chafa**](https://github.com/hpjansson/chafa) or [**kitty's icat**](https://sw.kovidgoyal.net/kitty/kittens/icat/) - For image previews in the terminal.
|
||||
* **Recommended for Downloads & Advanced Features:**
|
||||
* [**ffmpeg**](https://www.ffmpeg.org/) - Required for downloading HLS streams and merging subtitles.
|
||||
* [**webtorrent-cli**](https://github.com/webtorrent/webtorrent-cli) - For streaming torrents directly.
|
||||
|
||||
### Recommended Installation (uv)
|
||||
|
||||
The recommended installation method is with [uv](https://docs.astral.sh/uv/), a fast Python package manager.
|
||||
The best way to install Viu is with [**uv**](https://github.com/astral-sh/uv), a lightning-fast Python package manager.
|
||||
|
||||
```bash
|
||||
# Install with all optional features (recommended for the full experience)
|
||||
uv tool install "fastanime[standard]"
|
||||
# Install with all optional features for the full experience
|
||||
uv tool install "viu-media[standard]"
|
||||
|
||||
# Stripped-down installations
|
||||
uv tool install fastanime # Core functionality only
|
||||
uv tool install "fastanime[download]" # For advanced downloading
|
||||
uv tool install "fastanime[discord]" # For Discord Rich Presence
|
||||
uv tool install "fastanime[notifications]" # For desktop notifications
|
||||
# Or, pick and choose the extras you need:
|
||||
uv tool install viu-media # Core functionality only
|
||||
uv tool install "viu-media[download]" # For advanced downloading with yt-dlp
|
||||
uv tool install "viu-media[discord]" # For Discord Rich Presence
|
||||
uv tool install "viu-media[notifications]" # For desktop notifications
|
||||
```
|
||||
|
||||
### Other Installation Methods
|
||||
|
||||
<details>
|
||||
<summary><b>pipx or pip</b></summary>
|
||||
<summary><b>Platform-Specific and Alternative Installers</b></summary>
|
||||
|
||||
#### Using pipx (Recommended for isolated environments)
|
||||
#### Nix / NixOS
|
||||
```bash
|
||||
pipx install "fastanime[standard]"
|
||||
nix profile install github:Benexl/viu
|
||||
```
|
||||
|
||||
#### Arch Linux (AUR)
|
||||
Use an AUR helper like `yay` or `paru`.
|
||||
```bash
|
||||
# Stable version (recommended)
|
||||
yay -S viu
|
||||
|
||||
# Git version (latest commit)
|
||||
yay -S viu-git
|
||||
```
|
||||
|
||||
#### Using pipx (for isolated environments)
|
||||
```bash
|
||||
pipx install "viu-media[standard]"
|
||||
```
|
||||
|
||||
#### Using pip
|
||||
```bash
|
||||
pip install "fastanime[standard]"
|
||||
pip install "viu-media[standard]"
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Bleeding Edge & Building from Source</b></summary>
|
||||
<summary><b>Building from Source</b></summary>
|
||||
|
||||
### Installing the Bleeding Edge Version
|
||||
Download the latest `fastanime_debug_build` artifact from the [GitHub Actions page](https://github.com/Benexl/FastAnime/actions), then:
|
||||
Requires [Git](https://git-scm.com/), [Python 3.10+](https://www.python.org/), and [uv](https://astral.sh/blog/uv).
|
||||
```bash
|
||||
unzip fastanime_debug_build.zip
|
||||
uv tool install fastanime-*.whl
|
||||
```
|
||||
|
||||
### Building from Source
|
||||
Requirements: [Git](https://git-scm.com/), [Python 3.10+](https://www.python.org/), and [uv](https://astral.sh/blog/uv).
|
||||
```bash
|
||||
git clone https://github.com/Benexl/FastAnime.git --depth 1
|
||||
cd FastAnime
|
||||
git clone https://github.com/Benexl/Viu.git --depth 1
|
||||
cd Viu
|
||||
uv tool install .
|
||||
fastanime --version
|
||||
viu --version
|
||||
```
|
||||
</details>
|
||||
|
||||
> [!TIP]
|
||||
> Enable shell completions for a much better experience by running `fastanime completions` and following the on-screen instructions for your shell.
|
||||
> Enable shell completions for a much better experience by running `viu completions` and following the on-screen instructions for your shell.
|
||||
|
||||
### External Dependencies
|
||||
## Getting Started: Quick Start
|
||||
|
||||
For the best experience, install these external tools:
|
||||
Get up and running in three simple steps:
|
||||
|
||||
* **Required for Streaming:**
|
||||
* [**mpv**](https://mpv.io/installation/) - The primary media player.
|
||||
* **Recommended for UI & Previews:**
|
||||
* [**fzf**](https://github.com/junegunn/fzf) - For a powerful fuzzy-finder interface.
|
||||
* [**chafa**](https://github.com/hpjansson/chafa) or [**kitty's icat**](https://sw.kovidgoyal.net/kitty/kittens/icat/) - For image previews in the terminal.
|
||||
* **Recommended for Downloads & Features:**
|
||||
* [**ffmpeg**](https://www.ffmpeg.org/) - Required for downloading HLS streams.
|
||||
* [**webtorrent-cli**](https://github.com/webtorrent/webtorrent-cli) - For streaming torrents.
|
||||
* [**syncplay**](https://syncplay.pl/) - To watch anime together with friends.
|
||||
* [**feh**](https://github.com/derf/feh) or **kitty's icat** - For the experimental manga mode.
|
||||
1. **Authenticate with AniList:**
|
||||
```bash
|
||||
viu anilist auth
|
||||
```
|
||||
This will open your browser. Authorize the app and paste the obtained token back into the terminal.
|
||||
|
||||
## Usage
|
||||
2. **Launch the Interactive TUI:**
|
||||
```bash
|
||||
viu anilist
|
||||
```
|
||||
|
||||
FastAnime offers a rich interactive TUI for browsing and a powerful CLI for scripting and automation.
|
||||
3. **Browse & Play:** Use your arrow keys to navigate the menus, select an anime, and choose an episode to stream instantly.
|
||||
|
||||
### Global Options
|
||||
## Usage Guide
|
||||
|
||||
Most options can be passed directly to the `fastanime` command to override your config for that session.
|
||||
|
||||
* `--provider <allanime|animepahe>`: Choose the streaming site to use.
|
||||
* `--selector <fzf|rofi|default>`: Choose the UI backend.
|
||||
* `--preview`, `--no-preview`: Enable/disable image and info previews (requires `fzf`).
|
||||
* `--dub`, `--sub`: Set preferred translation type.
|
||||
* `--icons`, `--no-icons`: Toggle UI icons.
|
||||
* `--log`, `--log-file`: Enable logging to stdout or a file for debugging.
|
||||
* `--rich-traceback`: Show detailed, formatted tracebacks on error.
|
||||
|
||||
### Main Commands
|
||||
|
||||
* `fastanime anilist`: The main entry point for the interactive TUI. Browse, search, and manage your lists.
|
||||
* `fastanime registry`: Manage your local database of anime. Sync, search, backup, and restore.
|
||||
* `fastanime download`: Scriptable command to download specific episodes.
|
||||
* `fastanime search`: Scriptable command to find and stream episodes directly.
|
||||
* `fastanime config`: Manage your configuration file.
|
||||
* `fastanime update`: Update FastAnime to the latest version.
|
||||
* `fastanime queue`: Add episodes to the background download queue.
|
||||
* `fastanime worker`: Run the background worker for downloads and notifications.
|
||||
|
||||
---
|
||||
|
||||
### Deep Dive: `fastanime anilist` (Interactive TUI)
|
||||
|
||||
This is the primary way to use FastAnime. Simply run `fastanime anilist` to launch a rich, interactive terminal experience. From here you can:
|
||||
### The Interactive TUI (`viu anilist`)
|
||||
|
||||
This is the main, user-friendly way to use Viu. It provides a rich terminal experience where you can:
|
||||
* Browse trending, popular, and seasonal anime.
|
||||
* Manage your personal lists (Watching, Completed, etc.) after logging in with `fastanime anilist auth`.
|
||||
* Manage your personal lists (Watching, Completed, Paused, etc.).
|
||||
* Search for any anime in the AniList database.
|
||||
* View detailed information, characters, recommendations, reviews, and airing schedules.
|
||||
* Stream or download episodes.
|
||||
* Stream or download episodes directly from the menus.
|
||||
|
||||
#### `anilist search` Subcommand
|
||||
### Powerful Searching (`viu anilist search`)
|
||||
|
||||
A powerful command to filter the AniList database directly from your terminal.
|
||||
Filter the entire AniList database with powerful command-line flags.
|
||||
|
||||
```bash
|
||||
# Search for anime from 2024, sorted by popularity, that is releasing and not on your list
|
||||
fastanime anilist search -y 2024 -s POPULARITY_DESC --status RELEASING --not-on-list
|
||||
viu anilist search -y 2024 -s POPULARITY_DESC --status RELEASING --not-on-list
|
||||
|
||||
# Find the most popular movies with the "Fantasy" genre
|
||||
fastanime anilist search -g Fantasy -f MOVIE -s POPULARITY_DESC
|
||||
viu anilist search -g Fantasy -f MOVIE -s POPULARITY_DESC
|
||||
|
||||
# Dump search results as JSON instead of launching the TUI
|
||||
fastanime anilist search -t "Demon Slayer" --dump-json
|
||||
viu anilist search -t "Demon Slayer" --dump-json
|
||||
```
|
||||
|
||||
#### `anilist download` Subcommand
|
||||
### Background Downloads (`viu queue` & `worker`)
|
||||
|
||||
Combines the power of `anilist search` with the `download` command, allowing you to batch-download based on filters.
|
||||
Viu includes a robust background downloading system.
|
||||
|
||||
1. **Add episodes to the queue:**
|
||||
```bash
|
||||
# Download episodes 1-12 of all fantasy anime that aired in Winter 2024
|
||||
fastanime anilist download --season WINTER -y 2024 -g Fantasy -r "0:12"
|
||||
# Add episodes 1-12 of Jujutsu Kaisen to the download queue
|
||||
viu queue add -t "Jujutsu Kaisen" -r "0:12"
|
||||
```
|
||||
2. **Start the worker process:**
|
||||
```bash
|
||||
# Run the worker in the foreground (press Ctrl+C to stop)
|
||||
viu worker
|
||||
|
||||
---
|
||||
# Or run it as a background process
|
||||
viu worker &
|
||||
```The worker will now process the queue, download your episodes, and check for notifications.
|
||||
|
||||
### Deep Dive: `fastanime registry` (Local Database)
|
||||
### Scriptable Commands (`download` & `search`)
|
||||
|
||||
FastAnime maintains a local registry of your anime for offline access, enhanced performance, and powerful data management.
|
||||
|
||||
* `registry sync`: Synchronize your local data with your remote AniList account.
|
||||
* `registry stats`: Show detailed statistics about your viewing habits.
|
||||
* `registry search`: Search your locally stored anime data.
|
||||
* `registry backup`: Create a compressed backup of your entire registry.
|
||||
* `registry restore`: Restore your data from a backup file.
|
||||
* `registry export/import`: Export your data to JSON/CSV for use in other applications.
|
||||
|
||||
---
|
||||
|
||||
### Scriptable Commands: `download` & `search`
|
||||
|
||||
These commands are designed for automation and quick access.
|
||||
These commands are designed for automation and quick, non-interactive tasks.
|
||||
|
||||
#### `download` Examples
|
||||
```bash
|
||||
# Download the latest 5 episodes of One Piece
|
||||
fastanime download -t "One Piece" -r "-5"
|
||||
viu download -t "One Piece" -r "-5"
|
||||
|
||||
# Download episodes 1 to 24, merge subtitles, and clean up original files
|
||||
fastanime download -t "Jujutsu Kaisen" -r "0:24" --merge --clean
|
||||
viu download -t "Jujutsu Kaisen" -r "0:24" --merge --clean
|
||||
```
|
||||
|
||||
#### `search` (Binging) Examples
|
||||
```bash
|
||||
# Start binging an anime from the first episode
|
||||
fastanime search -t "Attack on Titan" -r ":"
|
||||
viu search -t "Attack on Titan" -r ":"
|
||||
|
||||
# Watch the latest episode directly
|
||||
fastanime search -t "My Hero Academia" -r "-1"
|
||||
viu search -t "My Hero Academia" -r "-1"
|
||||
```
|
||||
---
|
||||
|
||||
### Local Data Management (`viu registry`)
|
||||
|
||||
Viu maintains a local database of your anime for offline access and enhanced performance.
|
||||
|
||||
* `registry sync`: Synchronize your local data with your remote AniList account.
|
||||
* `registry stats`: Show detailed statistics about your viewing habits.
|
||||
* `registry backup`: Create a compressed backup of your entire registry.
|
||||
* `registry restore`: Restore your data from a backup file.
|
||||
* `registry export/import`: Export/import your data to JSON/CSV for use in other applications.
|
||||
* `registry clean`: Clean up orphaned or invalid entries from your local database.
|
||||
|
||||
## Configuration
|
||||
|
||||
Viu is highly customizable. A default configuration file with detailed comments is created on the first run.
|
||||
|
||||
* **Find your config file:** `viu config --path`
|
||||
* **Edit in your default editor:** `viu config`
|
||||
* **Use the interactive wizard:** `viu config --interactive`
|
||||
|
||||
Most settings in the config file can be temporarily overridden with command-line flags (e.g., `viu --provider animepahe anilist`).
|
||||
|
||||
<details>
|
||||
<summary><b>Default Configuration (`config.ini`) Explained</b></summary>
|
||||
|
||||
```ini
|
||||
# [general] Section: Controls overall application behavior.
|
||||
[general]
|
||||
provider = allanime ; The default anime provider (allanime, animepahe).
|
||||
selector = fzf ; The interactive UI tool (fzf, rofi, default).
|
||||
preview = full ; Preview type in selectors (full, text, image, none).
|
||||
image_renderer = icat ; Tool for terminal image previews (icat, chafa).
|
||||
icons = True ; Display emoji icons in the UI.
|
||||
auto_select_anime_result = True ; Automatically select the best search match.
|
||||
...
|
||||
|
||||
# [stream] Section: Controls playback and streaming.
|
||||
[stream]
|
||||
player = mpv ; The media player to use (mpv, vlc).
|
||||
quality = 1080 ; Preferred stream quality (1080, 720, 480, 360).
|
||||
translation_type = sub ; Preferred audio/subtitle type (sub, dub).
|
||||
auto_next = False ; Automatically play the next episode.
|
||||
continue_from_watch_history = True ; Resume playback from where you left off.
|
||||
use_ipc = True ; Enable in-player controls via MPV's IPC.
|
||||
...
|
||||
|
||||
# [downloads] Section: Controls the downloader.
|
||||
[downloads]
|
||||
downloader = auto ; Downloader to use (auto, default, yt-dlp).
|
||||
downloads_dir = ... ; Directory to save downloaded anime.
|
||||
max_concurrent_downloads = 3 ; Number of parallel downloads in the worker.
|
||||
merge_subtitles = True ; Automatically merge subtitles into the video file.
|
||||
cleanup_after_merge = True ; Delete original files after merging.
|
||||
...
|
||||
|
||||
# [worker] Section: Controls the background worker process.
|
||||
[worker]
|
||||
enabled = True
|
||||
notification_check_interval = 15 ; How often to check for new episodes (minutes).
|
||||
download_check_interval = 5 ; How often to process the download queue (minutes).
|
||||
...
|
||||
```
|
||||
</details>
|
||||
|
||||
## Advanced Features
|
||||
|
||||
### MPV IPC Integration
|
||||
|
||||
When `use_ipc` is enabled, FastAnime provides powerful in-player controls without closing MPV.
|
||||
When `use_ipc = True` is set in your config, Viu provides powerful in-player controls without needing to close MPV.
|
||||
|
||||
#### Key Bindings
|
||||
**Key Bindings:**
|
||||
* `Shift+N`: Play the next episode.
|
||||
* `Shift+P`: Play the previous episode.
|
||||
* `Shift+R`: Reload the current episode.
|
||||
* `Shift+A`: Toggle auto-play for the next episode.
|
||||
* `Shift+T`: Toggle between `dub` and `sub`.
|
||||
|
||||
#### Script Messages (MPV Console)
|
||||
**Script Messages (For MPV Console):**
|
||||
* `script-message select-episode <number>`: Jump to a specific episode.
|
||||
* `script-message select-server <name>`: Switch to a different streaming server.
|
||||
|
||||
## Configuration
|
||||
### Running as a Service (Linux/systemd)
|
||||
|
||||
FastAnime is highly customizable via its configuration file, located at `~/.config/fastanime/config.ini` (path may vary by OS).
|
||||
Run `fastanime config --path` to find the exact location on your system.
|
||||
|
||||
A default configuration file with detailed comments is created on first run. You can edit it with `fastanime config` or use the interactive wizard with `fastanime config --interactive`.
|
||||
|
||||
<details>
|
||||
<summary><b>Default Configuration (`config.ini`)</b></summary>
|
||||
You can run the background worker as a systemd service for persistence.
|
||||
|
||||
1. Create a service file at `~/.config/systemd/user/viu-worker.service`:
|
||||
```ini
|
||||
[general]
|
||||
# The preferred watch history tracker (local,remote) in cases of conflicts
|
||||
preferred_tracker = local
|
||||
# The pygment style to use
|
||||
pygment_style = github-dark
|
||||
# The spinner to use
|
||||
preferred_spinner = smiley
|
||||
# The media database API to use (e.g., 'anilist', 'jikan').
|
||||
media_api = anilist
|
||||
# The default anime provider to use for scraping.
|
||||
provider = allanime
|
||||
# The interactive selector tool to use for menus.
|
||||
selector = fzf
|
||||
# Automatically select the best-matching search result from a provider.
|
||||
auto_select_anime_result = True
|
||||
# Display emoji icons in the user interface.
|
||||
icons = True
|
||||
# Type of preview to display in selectors.
|
||||
preview = full
|
||||
# The command-line tool to use for rendering images in the terminal.
|
||||
image_renderer = icat
|
||||
# The external application to use for viewing manga pages.
|
||||
manga_viewer = feh
|
||||
# Automatically check for new versions of FastAnime on startup.
|
||||
check_for_updates = True
|
||||
# Enable caching of network requests to speed up subsequent operations.
|
||||
cache_requests = True
|
||||
# Maximum lifetime for a cached request in DD:HH:MM format.
|
||||
max_cache_lifetime = 03:00:00
|
||||
# Attempt to normalize provider titles to match AniList titles.
|
||||
normalize_titles = True
|
||||
# Enable Discord Rich Presence to show your current activity.
|
||||
discord = False
|
||||
# Number of recently watched anime to keep in history.
|
||||
recent = 50
|
||||
[Unit]
|
||||
Description=Viu Background Worker
|
||||
After=network-online.target
|
||||
|
||||
[stream]
|
||||
# The media player to use for streaming.
|
||||
player = mpv
|
||||
# Preferred stream quality.
|
||||
quality = 1080
|
||||
# Preferred audio/subtitle language type.
|
||||
translation_type = sub
|
||||
# The default server to use from a provider. 'top' uses the first available.
|
||||
server = TOP
|
||||
# Automatically play the next episode when the current one finishes.
|
||||
auto_next = False
|
||||
# Automatically resume playback from the last known episode and position.
|
||||
continue_from_watch_history = True
|
||||
# Which watch history to prioritize: local file or remote AniList progress.
|
||||
preferred_watch_history = local
|
||||
# Automatically skip openings/endings if skip data is available.
|
||||
auto_skip = False
|
||||
# Percentage of an episode to watch before it's marked as complete.
|
||||
episode_complete_at = 80
|
||||
# The format selection string for yt-dlp.
|
||||
ytdlp_format = best[height<=1080]/bestvideo[height<=1080]+bestaudio/best
|
||||
# Prevent updating AniList progress to a lower episode number.
|
||||
force_forward_tracking = True
|
||||
# Default behavior for tracking progress on AniList.
|
||||
default_media_list_tracking = prompt
|
||||
# Preferred language code for subtitles (e.g., 'en', 'es').
|
||||
sub_lang = eng
|
||||
# Use IPC communication with the player for advanced features like episode navigation.
|
||||
use_ipc = True
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/path/to/your/viu worker --log
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
```
|
||||
*Replace `/path/to/your/viu` with the output of `which viu`.*
|
||||
|
||||
2. Enable and start the service:
|
||||
```bash
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable --now viu-worker.service
|
||||
```
|
||||
</details>
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests are highly welcome! Please read our [**Contributing Guidelines**](CONTRIBUTIONS.md) to get started with setting up a development environment and understanding our coding standards.
|
||||
Contributions are welcome! Whether it's reporting a bug, proposing a feature, or writing code, your help is appreciated. Please read our [**Contributing Guidelines**](CONTRIBUTIONS.md) to get started.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
> [!IMPORTANT]
|
||||
> This project scrapes public-facing websites. The developer(s) of this application have no affiliation with these content providers. This application hosts zero content and is intended for educational and personal use only. Use at your own risk.
|
||||
>
|
||||
> This project scrapes public-facing websites (`allanime`, `animepahe`). The developer(s) of this application have no affiliation with these content providers. This application hosts zero content. Use at your own risk.
|
||||
>
|
||||
> [**Full Disclaimer**](DISCLAIMER.md)
|
||||
> [**Read the Full Disclaimer**](DISCLAIMER.md)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FROM python:3.12-slim-bookworm
|
||||
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
|
||||
COPY . /fastanime
|
||||
COPY . /viu
|
||||
ENV PATH=/root/.local/bin:$PATH
|
||||
WORKDIR /fastanime
|
||||
WORKDIR /viu
|
||||
RUN uv tool install .
|
||||
CMD ["bash"]
|
||||
|
||||
@@ -5,7 +5,7 @@ block_cipher = None
|
||||
|
||||
# Collect all required data files
|
||||
datas = [
|
||||
('fastanime/assets/*', 'fastanime/assets'),
|
||||
('viu/assets/*', 'viu/assets'),
|
||||
]
|
||||
|
||||
# Collect all required hidden imports
|
||||
@@ -16,11 +16,11 @@ hiddenimports = [
|
||||
'yt_dlp',
|
||||
'python_mpv',
|
||||
'fuzzywuzzy',
|
||||
'fastanime',
|
||||
] + collect_submodules('fastanime')
|
||||
'viu',
|
||||
] + collect_submodules('viu')
|
||||
|
||||
a = Analysis(
|
||||
['./fastanime/fastanime.py'], # Changed entry point
|
||||
['./viu/viu.py'], # Changed entry point
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=datas,
|
||||
@@ -49,7 +49,7 @@ exe = EXE(
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='fastanime',
|
||||
name='viu',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=True,
|
||||
@@ -61,5 +61,5 @@ exe = EXE(
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
icon='fastanime/assets/logo.ico'
|
||||
icon='viu/assets/logo.ico'
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
_fastanime_completion() {
|
||||
_viu_completion() {
|
||||
local IFS=$'\n'
|
||||
local response
|
||||
|
||||
response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _FASTANIME_COMPLETE=bash_complete $1)
|
||||
response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _VIU_COMPLETE=bash_complete $1)
|
||||
|
||||
for completion in $response; do
|
||||
IFS=',' read type value <<< "$completion"
|
||||
@@ -21,9 +21,9 @@ _fastanime_completion() {
|
||||
return 0
|
||||
}
|
||||
|
||||
_fastanime_completion_setup() {
|
||||
complete -o nosort -F _fastanime_completion fastanime
|
||||
_viu_completion_setup() {
|
||||
complete -o nosort -F _viu_completion viu
|
||||
}
|
||||
|
||||
_fastanime_completion_setup;
|
||||
_viu_completion_setup;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function _fastanime_completion;
|
||||
set -l response (env _FASTANIME_COMPLETE=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) fastanime);
|
||||
function _viu_completion;
|
||||
set -l response (env _VIU_COMPLETE=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) viu);
|
||||
|
||||
for completion in $response;
|
||||
set -l metadata (string split "," $completion);
|
||||
@@ -14,5 +14,5 @@ function _fastanime_completion;
|
||||
end;
|
||||
end;
|
||||
|
||||
complete --no-files --command fastanime --arguments "(_fastanime_completion)";
|
||||
complete --no-files --command viu --arguments "(_viu_completion)";
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#compdef fastanime
|
||||
#compdef viu
|
||||
|
||||
_fastanime_completion() {
|
||||
_viu_completion() {
|
||||
local -a completions
|
||||
local -a completions_with_descriptions
|
||||
local -a response
|
||||
(( ! $+commands[fastanime] )) && return 1
|
||||
(( ! $+commands[viu] )) && return 1
|
||||
|
||||
response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _FASTANIME_COMPLETE=zsh_complete fastanime)}")
|
||||
response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _VIU_COMPLETE=zsh_complete viu)}")
|
||||
|
||||
for type key descr in ${response}; do
|
||||
if [[ "$type" == "plain" ]]; then
|
||||
@@ -33,9 +33,9 @@ _fastanime_completion() {
|
||||
|
||||
if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
|
||||
# autoload from fpath, call function directly
|
||||
_fastanime_completion "$@"
|
||||
_viu_completion "$@"
|
||||
else
|
||||
# eval/source/. command, register function for later
|
||||
compdef _fastanime_completion fastanime
|
||||
compdef _viu_completion viu
|
||||
fi
|
||||
|
||||
6
dev/generate_completions.sh
Executable file → Normal file
6
dev/generate_completions.sh
Executable file → Normal file
@@ -5,10 +5,10 @@ APP_DIR="$(
|
||||
)"
|
||||
|
||||
# fish shell completions
|
||||
_FASTANIME_COMPLETE=fish_source fastanime >"$APP_DIR/completions/fastanime.fish"
|
||||
_VIU_COMPLETE=fish_source viu >"$APP_DIR/completions/viu.fish"
|
||||
|
||||
# zsh completions
|
||||
_FASTANIME_COMPLETE=zsh_source fastanime >"$APP_DIR/completions/fastanime.zsh"
|
||||
_VIU_COMPLETE=zsh_source viu >"$APP_DIR/completions/viu.zsh"
|
||||
|
||||
# bash completions
|
||||
_FASTANIME_COMPLETE=bash_source fastanime >"$APP_DIR/completions/fastanime.bash"
|
||||
_VIU_COMPLETE=bash_source viu >"$APP_DIR/completions/viu.bash"
|
||||
|
||||
6
dev/make_release
Executable file → Normal file
6
dev/make_release
Executable file → Normal file
@@ -2,11 +2,11 @@
|
||||
CLI_DIR="$(dirname "$(realpath "$0")")"
|
||||
VERSION=$1
|
||||
[ -z "$VERSION" ] && echo no version provided && exit 1
|
||||
[ "$VERSION" = "current" ] && fastanime --version && exit 0
|
||||
[ "$VERSION" = "current" ] && viu --version && exit 0
|
||||
sed -i "s/^version.*/version = \"$VERSION\"/" "$CLI_DIR/pyproject.toml" &&
|
||||
sed -i "s/__version__.*/__version__ = \"v$VERSION\"/" "$CLI_DIR/fastanime/__init__.py" &&
|
||||
sed -i "s/__version__.*/__version__ = \"v$VERSION\"/" "$CLI_DIR/viu/__init__.py" &&
|
||||
sed -i "s/version = .*/version = \"$VERSION\";/" "$CLI_DIR/flake.nix" &&
|
||||
git stage "$CLI_DIR/pyproject.toml" "$CLI_DIR/fastanime/__init__.py" "$CLI_DIR/flake.nix" &&
|
||||
git stage "$CLI_DIR/pyproject.toml" "$CLI_DIR/viu/__init__.py" "$CLI_DIR/flake.nix" &&
|
||||
git commit -m "chore: bump version (v$VERSION)" &&
|
||||
# nix flake lock &&
|
||||
uv lock &&
|
||||
|
||||
15
examples/plugins/player/config.toml
Normal file
15
examples/plugins/player/config.toml
Normal file
@@ -0,0 +1,15 @@
|
||||
[multi-file-provider]
|
||||
# Base URL for the anime site
|
||||
base_url = "https://multifile.example.site"
|
||||
|
||||
# Request timeout in seconds
|
||||
timeout = 30
|
||||
|
||||
# Preferred video quality
|
||||
preferred_quality = "720p"
|
||||
|
||||
# Maximum number of search results
|
||||
max_results = 25
|
||||
|
||||
# Enable debug logging
|
||||
debug = false
|
||||
169
examples/plugins/player/player.py
Normal file
169
examples/plugins/player/player.py
Normal file
@@ -0,0 +1,169 @@
|
||||
"""
|
||||
VLC player integration for Viu.
|
||||
|
||||
This module provides the VlcPlayer class, which implements the BasePlayer interface for the VLC media player.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from viu_media.core.config import VlcConfig
|
||||
from viu_media.core.exceptions import ViuError
|
||||
from viu_media.core.patterns import TORRENT_REGEX, YOUTUBE_REGEX
|
||||
from viu_media.core.utils import detect
|
||||
from viu_media.libs.player.base import BasePlayer
|
||||
from viu_media.libs.player.params import PlayerParams
|
||||
from viu_media.libs.player.types import PlayerResult
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class VlcPlayer(BasePlayer):
|
||||
"""
|
||||
VLC player implementation for Viu.
|
||||
|
||||
Provides playback functionality using the VLC media player, supporting desktop, mobile, and torrent scenarios.
|
||||
"""
|
||||
|
||||
def __init__(self, config: VlcConfig):
|
||||
"""
|
||||
Initialize the VlcPlayer with the given VLC configuration.
|
||||
|
||||
Args:
|
||||
config: VlcConfig object containing VLC-specific settings.
|
||||
"""
|
||||
self.config = config
|
||||
self.executable = shutil.which("vlc")
|
||||
|
||||
def play(self, params: PlayerParams) -> PlayerResult:
|
||||
"""
|
||||
Play the given media using VLC, handling desktop, mobile, and torrent scenarios.
|
||||
|
||||
Args:
|
||||
params: PlayerParams object containing playback parameters.
|
||||
|
||||
Returns:
|
||||
PlayerResult: Information about the playback session.
|
||||
"""
|
||||
if not self.executable:
|
||||
raise ViuError("VLC executable not found in PATH.")
|
||||
|
||||
if TORRENT_REGEX.match(params.url) and detect.is_running_in_termux():
|
||||
return self._play_on_mobile(params)
|
||||
else:
|
||||
return self._play_on_desktop(params)
|
||||
|
||||
def play_with_ipc(self, params: PlayerParams, socket_path: str) -> subprocess.Popen:
|
||||
"""
|
||||
Not implemented for VLC player.
|
||||
"""
|
||||
raise NotImplementedError("play_with_ipc is not implemented for VLC player.")
|
||||
|
||||
def _play_on_mobile(self, params: PlayerParams) -> PlayerResult:
|
||||
"""
|
||||
Play media on a mobile device using Android intents.
|
||||
|
||||
Args:
|
||||
params: PlayerParams object containing playback parameters.
|
||||
|
||||
Returns:
|
||||
PlayerResult: Information about the playback session.
|
||||
"""
|
||||
if YOUTUBE_REGEX.match(params.url):
|
||||
args = [
|
||||
"nohup",
|
||||
"am",
|
||||
"start",
|
||||
"--user",
|
||||
"0",
|
||||
"-a",
|
||||
"android.intent.action.VIEW",
|
||||
"-d",
|
||||
params.url,
|
||||
"-n",
|
||||
"com.google.android.youtube/.UrlActivity",
|
||||
]
|
||||
else:
|
||||
args = [
|
||||
"nohup",
|
||||
"am",
|
||||
"start",
|
||||
"--user",
|
||||
"0",
|
||||
"-a",
|
||||
"android.intent.action.VIEW",
|
||||
"-d",
|
||||
params.url,
|
||||
"-n",
|
||||
"org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity",
|
||||
"-e",
|
||||
"title",
|
||||
params.title,
|
||||
]
|
||||
|
||||
subprocess.run(args)
|
||||
|
||||
return PlayerResult(episode=params.episode)
|
||||
|
||||
def _play_on_desktop(self, params: PlayerParams) -> PlayerResult:
|
||||
"""
|
||||
Play media on a desktop environment using VLC.
|
||||
|
||||
Args:
|
||||
params: PlayerParams object containing playback parameters.
|
||||
|
||||
Returns:
|
||||
PlayerResult: Information about the playback session.
|
||||
"""
|
||||
if TORRENT_REGEX.search(params.url):
|
||||
return self._stream_on_desktop_with_webtorrent_cli(params)
|
||||
|
||||
args = [self.executable, params.url]
|
||||
if params.subtitles:
|
||||
for sub in params.subtitles:
|
||||
args.extend(["--sub-file", sub])
|
||||
break
|
||||
if params.title:
|
||||
args.extend(["--video-title", params.title])
|
||||
|
||||
if self.config.args:
|
||||
args.extend(self.config.args.split(","))
|
||||
|
||||
subprocess.run(args, encoding="utf-8")
|
||||
return PlayerResult(episode=params.episode)
|
||||
|
||||
def _stream_on_desktop_with_webtorrent_cli(
|
||||
self, params: PlayerParams
|
||||
) -> PlayerResult:
|
||||
"""
|
||||
Stream torrent media using the webtorrent CLI and VLC.
|
||||
|
||||
Args:
|
||||
params: PlayerParams object containing playback parameters.
|
||||
|
||||
Returns:
|
||||
PlayerResult: Information about the playback session.
|
||||
"""
|
||||
WEBTORRENT_CLI = shutil.which("webtorrent")
|
||||
if not WEBTORRENT_CLI:
|
||||
raise ViuError("Please Install webtorrent cli inorder to stream torrents")
|
||||
|
||||
args = [WEBTORRENT_CLI, params.url, "--vlc"]
|
||||
|
||||
if self.config.args:
|
||||
args.append("--player-args")
|
||||
args.extend(self.config.args.split(","))
|
||||
|
||||
subprocess.run(args)
|
||||
return PlayerResult(episode=params.episode)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from viu_media.core.constants import APP_ASCII_ART
|
||||
|
||||
print(APP_ASCII_ART)
|
||||
url = input("Enter the url you would like to stream: ")
|
||||
vlc = VlcPlayer(VlcConfig())
|
||||
player_result = vlc.play(PlayerParams(url=url, title="", query="", episode=""))
|
||||
print(player_result)
|
||||
9
examples/plugins/player/plugin.info.toml
Normal file
9
examples/plugins/player/plugin.info.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
[plugin]
|
||||
name = "Multi-File Provider Plugin"
|
||||
version = "1.0.0"
|
||||
description = "A demo plugin with multiple Python files"
|
||||
author = "Viu Developer"
|
||||
requires_python = ">=3.11"
|
||||
|
||||
[components]
|
||||
player = "player:VlcPlayer"
|
||||
18
examples/plugins/provider/config.toml
Normal file
18
examples/plugins/provider/config.toml
Normal file
@@ -0,0 +1,18 @@
|
||||
# Default configuration for Example Provider Plugin
|
||||
# This file is automatically copied to ~/.config/viu/plugins.config.toml during installation
|
||||
|
||||
[example-provider]
|
||||
# Request timeout in seconds
|
||||
timeout = 30
|
||||
|
||||
# Preferred video quality
|
||||
preferred_quality = "720p"
|
||||
|
||||
# Maximum number of search results to return
|
||||
max_results = 20
|
||||
|
||||
# Custom headers (optional)
|
||||
# custom_header = "value"
|
||||
|
||||
# Enable debug logging for this plugin
|
||||
# debug = false
|
||||
100
examples/plugins/provider/mappers.py
Normal file
100
examples/plugins/provider/mappers.py
Normal file
@@ -0,0 +1,100 @@
|
||||
from typing import Any
|
||||
|
||||
from viu_media.libs.provider.anime.types import (
|
||||
Anime,
|
||||
AnimeEpisodeInfo,
|
||||
AnimeEpisodes,
|
||||
EpisodeStream,
|
||||
MediaTranslationType,
|
||||
PageInfo,
|
||||
SearchResult,
|
||||
SearchResults,
|
||||
Server,
|
||||
)
|
||||
|
||||
from .types import (
|
||||
AnimePaheAnimePage,
|
||||
AnimePaheSearchPage,
|
||||
)
|
||||
|
||||
translation_type_map = {
|
||||
"sub": MediaTranslationType.SUB,
|
||||
"dub": MediaTranslationType.DUB,
|
||||
"raw": MediaTranslationType.RAW,
|
||||
}
|
||||
|
||||
|
||||
def map_to_search_results(data: AnimePaheSearchPage) -> SearchResults:
|
||||
results = []
|
||||
for result in data["data"]:
|
||||
results.append(
|
||||
SearchResult(
|
||||
id=result["session"],
|
||||
title=result["title"],
|
||||
episodes=AnimeEpisodes(
|
||||
sub=list(map(str, range(1, result["episodes"] + 1))),
|
||||
dub=list(map(str, range(1, result["episodes"] + 1))),
|
||||
raw=list(map(str, range(1, result["episodes"] + 1))),
|
||||
),
|
||||
media_type=result["type"],
|
||||
score=result["score"],
|
||||
status=result["status"],
|
||||
season=result["season"],
|
||||
poster=result["poster"],
|
||||
year=str(result["year"]),
|
||||
)
|
||||
)
|
||||
|
||||
return SearchResults(
|
||||
page_info=PageInfo(
|
||||
total=data["total"],
|
||||
per_page=data["per_page"],
|
||||
current_page=data["current_page"],
|
||||
),
|
||||
results=results,
|
||||
)
|
||||
|
||||
|
||||
def map_to_anime_result(
|
||||
search_result: SearchResult, anime: AnimePaheAnimePage
|
||||
) -> Anime:
|
||||
episodes_info = []
|
||||
episodes = []
|
||||
anime["data"] = sorted(anime["data"], key=lambda k: float(k["episode"]))
|
||||
for ep_info in anime["data"]:
|
||||
episodes.append(str(ep_info["episode"]))
|
||||
episodes_info.append(
|
||||
AnimeEpisodeInfo(
|
||||
id=str(ep_info["id"]),
|
||||
session_id=ep_info["session"],
|
||||
episode=str(ep_info["episode"]),
|
||||
title=ep_info["title"],
|
||||
poster=ep_info["snapshot"],
|
||||
duration=str(ep_info["duration"]),
|
||||
)
|
||||
)
|
||||
|
||||
return Anime(
|
||||
id=search_result.id,
|
||||
title=search_result.title,
|
||||
episodes=AnimeEpisodes(
|
||||
sub=episodes,
|
||||
dub=episodes,
|
||||
),
|
||||
year=str(search_result.year),
|
||||
poster=search_result.poster,
|
||||
episodes_info=episodes_info,
|
||||
)
|
||||
|
||||
|
||||
def map_to_server(
|
||||
episode: AnimeEpisodeInfo, translation_type: Any, quality: Any, stream_link: Any
|
||||
) -> Server:
|
||||
links = [
|
||||
EpisodeStream(
|
||||
link=stream_link,
|
||||
quality=quality,
|
||||
translation_type=translation_type_map[translation_type],
|
||||
)
|
||||
]
|
||||
return Server(name="kwik", links=links, episode_title=episode.title)
|
||||
10
examples/plugins/provider/plugin.info.toml
Normal file
10
examples/plugins/provider/plugin.info.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[plugin]
|
||||
name = "Example Provider Plugin"
|
||||
version = "1.0.0"
|
||||
description = "A demo provider plugin for testing the viu plugin system"
|
||||
author = "Viu Developer"
|
||||
homepage = "https://github.com/example/viu-example-plugin"
|
||||
requires_python = ">=3.11"
|
||||
|
||||
[components]
|
||||
provider = "example_provider:ExampleProvider"
|
||||
207
examples/plugins/provider/provider.py
Normal file
207
examples/plugins/provider/provider.py
Normal file
@@ -0,0 +1,207 @@
|
||||
import logging
|
||||
from functools import lru_cache
|
||||
from typing import Iterator, Optional
|
||||
|
||||
from viu_media.libs.provider.anime.base import BaseAnimeProvider
|
||||
from viu_media.libs.provider.anime.params import (
|
||||
AnimeParams,
|
||||
EpisodeStreamsParams,
|
||||
SearchParams,
|
||||
)
|
||||
from viu_media.libs.provider.anime.types import (
|
||||
Anime,
|
||||
AnimeEpisodeInfo,
|
||||
SearchResult,
|
||||
SearchResults,
|
||||
Server,
|
||||
)
|
||||
from viu_media.libs.provider.anime.utils.debug import debug_provider
|
||||
|
||||
from .constants import (
|
||||
ANIMEPAHE_BASE,
|
||||
ANIMEPAHE_ENDPOINT,
|
||||
JUICY_STREAM_REGEX,
|
||||
REQUEST_HEADERS,
|
||||
SERVER_HEADERS,
|
||||
)
|
||||
from .extractor import process_animepahe_embed_page
|
||||
from .mappers import map_to_anime_result, map_to_search_results, map_to_server
|
||||
from .types import AnimePaheAnimePage, AnimePaheSearchPage
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AnimePahe(BaseAnimeProvider):
|
||||
HEADERS = REQUEST_HEADERS
|
||||
|
||||
@debug_provider
|
||||
def search(self, params: SearchParams) -> SearchResults | None:
|
||||
return self._search(params)
|
||||
|
||||
@lru_cache()
|
||||
def _search(self, params: SearchParams) -> SearchResults | None:
|
||||
url_params = {"m": "search", "q": params.query}
|
||||
response = self.client.get(ANIMEPAHE_ENDPOINT, params=url_params)
|
||||
response.raise_for_status()
|
||||
data: AnimePaheSearchPage = response.json()
|
||||
if not data.get("data"):
|
||||
return
|
||||
return map_to_search_results(data)
|
||||
|
||||
@debug_provider
|
||||
def get(self, params: AnimeParams) -> Anime | None:
|
||||
return self._get_anime(params)
|
||||
|
||||
@lru_cache()
|
||||
def _get_anime(self, params: AnimeParams) -> Anime | None:
|
||||
page = 1
|
||||
standardized_episode_number = 0
|
||||
|
||||
search_result = self._get_search_result(params)
|
||||
if not search_result:
|
||||
logger.error(f"No search result found for ID {params.id}")
|
||||
return None
|
||||
|
||||
anime: Optional[AnimePaheAnimePage] = None
|
||||
|
||||
has_next_page = True
|
||||
while has_next_page:
|
||||
logger.debug(f"Loading page: {page}")
|
||||
_anime_page = self._anime_page_loader(
|
||||
m="release",
|
||||
id=params.id,
|
||||
sort="episode_asc",
|
||||
page=page,
|
||||
)
|
||||
|
||||
has_next_page = True if _anime_page["next_page_url"] else False
|
||||
page += 1
|
||||
if not anime:
|
||||
anime = _anime_page
|
||||
else:
|
||||
anime["data"].extend(_anime_page["data"])
|
||||
|
||||
if anime:
|
||||
for episode in anime.get("data", []):
|
||||
if episode["episode"] % 1 == 0:
|
||||
standardized_episode_number += 1
|
||||
episode.update({"episode": standardized_episode_number})
|
||||
else:
|
||||
standardized_episode_number += episode["episode"] % 1
|
||||
episode.update({"episode": standardized_episode_number})
|
||||
standardized_episode_number = int(standardized_episode_number)
|
||||
|
||||
return map_to_anime_result(search_result, anime)
|
||||
|
||||
@lru_cache()
|
||||
def _get_search_result(self, params: AnimeParams) -> Optional[SearchResult]:
|
||||
search_results = self._search(SearchParams(query=params.query))
|
||||
if not search_results or not search_results.results:
|
||||
logger.error(f"No search results found for ID {params.id}")
|
||||
return None
|
||||
for search_result in search_results.results:
|
||||
if search_result.id == params.id:
|
||||
return search_result
|
||||
|
||||
@lru_cache()
|
||||
def _anime_page_loader(self, m, id, sort, page) -> AnimePaheAnimePage:
|
||||
url_params = {
|
||||
"m": m,
|
||||
"id": id,
|
||||
"sort": sort,
|
||||
"page": page,
|
||||
}
|
||||
response = self.client.get(ANIMEPAHE_ENDPOINT, params=url_params)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
@debug_provider
|
||||
def episode_streams(self, params: EpisodeStreamsParams) -> Iterator[Server] | None:
|
||||
from viu_media.libs.provider.scraping.html_parser import (
|
||||
extract_attributes,
|
||||
get_element_by_id,
|
||||
get_elements_html_by_class,
|
||||
)
|
||||
|
||||
episode = self._get_episode_info(params)
|
||||
if not episode:
|
||||
logger.error(
|
||||
f"Episode {params.episode} doesn't exist for anime {params.anime_id}"
|
||||
)
|
||||
return
|
||||
|
||||
url = f"{ANIMEPAHE_BASE}/play/{params.anime_id}/{episode.session_id}"
|
||||
response = self.client.get(url, follow_redirects=True)
|
||||
response.raise_for_status()
|
||||
|
||||
c = get_element_by_id("resolutionMenu", response.text)
|
||||
if not c:
|
||||
logger.error("Resolution menu not found in the response")
|
||||
return
|
||||
resolutionMenuItems = get_elements_html_by_class("dropdown-item", c)
|
||||
res_dicts = [extract_attributes(item) for item in resolutionMenuItems]
|
||||
quality = None
|
||||
translation_type = None
|
||||
stream_link = None
|
||||
|
||||
# TODO: better document the scraping process
|
||||
for res_dict in res_dicts:
|
||||
# the actual attributes are data attributes in the original html 'prefixed with data-'
|
||||
embed_url = res_dict["src"]
|
||||
data_audio = "dub" if res_dict["audio"] == "eng" else "sub"
|
||||
|
||||
if data_audio != params.translation_type:
|
||||
continue
|
||||
|
||||
if not embed_url:
|
||||
logger.warning("embed url not found please report to the developers")
|
||||
continue
|
||||
|
||||
embed_response = self.client.get(
|
||||
embed_url,
|
||||
headers={
|
||||
"User-Agent": self.client.headers["User-Agent"],
|
||||
**SERVER_HEADERS,
|
||||
},
|
||||
)
|
||||
embed_response.raise_for_status()
|
||||
embed_page = embed_response.text
|
||||
|
||||
decoded_js = process_animepahe_embed_page(embed_page)
|
||||
if not decoded_js:
|
||||
logger.error("failed to decode embed page")
|
||||
continue
|
||||
juicy_stream = JUICY_STREAM_REGEX.search(decoded_js)
|
||||
if not juicy_stream:
|
||||
logger.error("failed to find juicy stream")
|
||||
continue
|
||||
juicy_stream = juicy_stream.group(1)
|
||||
quality = res_dict["resolution"]
|
||||
translation_type = data_audio
|
||||
stream_link = juicy_stream
|
||||
|
||||
if translation_type and quality and stream_link:
|
||||
yield map_to_server(episode, translation_type, quality, stream_link)
|
||||
|
||||
@lru_cache()
|
||||
def _get_episode_info(
|
||||
self, params: EpisodeStreamsParams
|
||||
) -> Optional[AnimeEpisodeInfo]:
|
||||
anime_info = self._get_anime(
|
||||
AnimeParams(id=params.anime_id, query=params.query)
|
||||
)
|
||||
if not anime_info:
|
||||
logger.error(f"No anime info for {params.anime_id}")
|
||||
return
|
||||
if not anime_info.episodes_info:
|
||||
logger.error(f"No episodes info for {params.anime_id}")
|
||||
return
|
||||
for episode in anime_info.episodes_info:
|
||||
if episode.episode == params.episode:
|
||||
return episode
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from viu_media.libs.provider.anime.utils.debug import test_anime_provider
|
||||
|
||||
test_anime_provider(AnimePahe)
|
||||
@@ -1,6 +0,0 @@
|
||||
███████╗░█████╗░░██████╗████████╗░█████╗░███╗░░██╗██╗███╗░░░███╗███████╗
|
||||
██╔════╝██╔══██╗██╔════╝╚══██╔══╝██╔══██╗████╗░██║██║████╗░████║██╔════╝
|
||||
█████╗░░███████║╚█████╗░░░░██║░░░███████║██╔██╗██║██║██╔████╔██║█████╗░░
|
||||
██╔══╝░░██╔══██║░╚═══██╗░░░██║░░░██╔══██║██║╚████║██║██║╚██╔╝██║██╔══╝░░
|
||||
██║░░░░░██║░░██║██████╔╝░░░██║░░░██║░░██║██║░╚███║██║██║░╚═╝░██║███████╗
|
||||
╚═╝░░░░░╚═╝░░╚═╝╚═════╝░░░░╚═╝░░░╚═╝░░╚═╝╚═╝░░╚══╝╚═╝╚═╝░░░░░╚═╝╚══════╝
|
||||
@@ -1,55 +0,0 @@
|
||||
configuration {
|
||||
font: "Sans 12";
|
||||
}
|
||||
|
||||
* {
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
text-color: #FFFFFF;
|
||||
}
|
||||
|
||||
window {
|
||||
fullscreen: true;
|
||||
transparency: "real";
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
mainbox {
|
||||
children: [ message, listview, inputbar ];
|
||||
padding: 40% 30%;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
message {
|
||||
border: 0;
|
||||
padding: 10px;
|
||||
border-radius:20px;
|
||||
margin: 0 0 20px 0;
|
||||
font: "Sans Bold 24"; /* Increased font size and made it bold */
|
||||
}
|
||||
|
||||
inputbar {
|
||||
children: [ prompt, entry ];
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
prompt {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
entry {
|
||||
padding: 8px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
listview {
|
||||
lines: 0;
|
||||
}
|
||||
|
||||
/* Style for the message text specifically */
|
||||
textbox {
|
||||
horizontal-align: 0.5; /* Center the text */
|
||||
font: "Sans Bold 24"; /* Match message font */
|
||||
background-color: transparent;
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
configuration {
|
||||
font: "Sans 12";
|
||||
}
|
||||
|
||||
* {
|
||||
background-color: rgba(0, 0, 0, 0.7);
|
||||
text-color: #FFFFFF;
|
||||
}
|
||||
|
||||
window {
|
||||
fullscreen: true;
|
||||
transparency: "real";
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
mainbox {
|
||||
children: [ message, listview, inputbar ];
|
||||
padding: 40% 30%;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
message {
|
||||
border: 0;
|
||||
padding: 10px;
|
||||
border-radius:20px;
|
||||
margin: 0 0 20px 0;
|
||||
font: "Sans Bold 24"; /* Increased font size and made it bold */
|
||||
}
|
||||
|
||||
inputbar {
|
||||
children: [ prompt, entry ];
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
prompt {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
entry {
|
||||
padding: 8px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
listview {
|
||||
lines: 0;
|
||||
}
|
||||
|
||||
/* Style for the message text specifically */
|
||||
textbox {
|
||||
horizontal-align: 0.5; /* Center the text */
|
||||
font: "Sans Bold 24"; /* Match message font */
|
||||
background-color: transparent;
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
configuration {
|
||||
font: "Sans 12";
|
||||
line-margin: 10;
|
||||
display-drun: "";
|
||||
}
|
||||
|
||||
* {
|
||||
background: #000000; /* Black background for everything */
|
||||
background-alt: #000000; /* Ensures no alternation */
|
||||
foreground: #CCCCCC;
|
||||
selected: #3584E4;
|
||||
active: #2E7D32;
|
||||
urgent: #C62828;
|
||||
}
|
||||
|
||||
window {
|
||||
fullscreen: false;
|
||||
background-color: rgba(0, 0, 0, 0.8); /* Solid black transparent background */
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
mainbox {
|
||||
padding: 50px 50px;
|
||||
background-color: transparent; /* Ensures black background fills entire main area */
|
||||
children: [inputbar, listview];
|
||||
spacing: 20px;
|
||||
}
|
||||
|
||||
inputbar {
|
||||
background-color: #333333; /* Dark gray background for input bar */
|
||||
padding: 8px;
|
||||
border-radius: 8px;
|
||||
children: [prompt, entry];
|
||||
}
|
||||
|
||||
prompt {
|
||||
enabled: true;
|
||||
padding: 8px;
|
||||
background-color: @selected;
|
||||
text-color: #000000;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
entry {
|
||||
padding: 8px;
|
||||
background-color: transparent; /* Slightly lighter gray for visibility */
|
||||
text-color: #FFFFFF; /* White text to make typing visible */
|
||||
placeholder: "Search...";
|
||||
placeholder-color: rgba(255, 255, 255, 0.5);
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
listview {
|
||||
layout: vertical;
|
||||
spacing: 8px;
|
||||
lines: 9;
|
||||
background-color: transparent; /* Consistent black background for list items */
|
||||
}
|
||||
|
||||
element {
|
||||
padding: 12px;
|
||||
border-radius: 4px;
|
||||
background-color: transparent; /* Uniform color for each list item */
|
||||
text-color: @foreground;
|
||||
}
|
||||
|
||||
element normal.normal {
|
||||
background-color: transparent; /* Ensures no alternating color */
|
||||
}
|
||||
|
||||
element selected.normal {
|
||||
background-color: @selected;
|
||||
text-color: #FFFFFF;
|
||||
}
|
||||
|
||||
element-text {
|
||||
background-color: transparent;
|
||||
text-color: inherit;
|
||||
vertical-align: 0.5;
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
// Colours
|
||||
* {
|
||||
background-color: transparent; /* Transparent background for the global UI */
|
||||
background: #000000; /* Solid black background */
|
||||
background-transparent: #1D2330A0; /* Semi-transparent background */
|
||||
text-color: #BBBBBB; /* Default text color (light gray) */
|
||||
text-color-selected: #FFFFFF; /* Text color when selected (white) */
|
||||
primary: rgba(53, 132, 228, 0.75); /* Blusish primary color */
|
||||
important: rgba(53, 132, 228, 0.75); /* Bluish primary color */
|
||||
}
|
||||
|
||||
configuration {
|
||||
font: "Roboto 14"; /* Sets the global font to Roboto, size 14 */
|
||||
show-icons: true; /* Option to display icons in the UI */
|
||||
}
|
||||
|
||||
window {
|
||||
fullscreen: true; /* The window will open in fullscreen */
|
||||
height: 100%; /* Full window height */
|
||||
width: 100%; /* Full window width */
|
||||
transparency: "real"; /* Real transparency effect */
|
||||
background-color: @background-transparent; /* Transparent background */
|
||||
border: 0px; /* No border around the window */
|
||||
border-color: @primary; /* Border color set to the primary color */
|
||||
}
|
||||
|
||||
mainbox {
|
||||
children: [prompt, inputbar-box, listview]; /* Main box contains prompt, input bar, and list view */
|
||||
padding: 0px; /* No padding around the main box */
|
||||
}
|
||||
|
||||
prompt {
|
||||
width: 100%; /* Prompt takes full width */
|
||||
margin: 10px 0px 0px 30px; /* Margin around the prompt */
|
||||
text-color: @important; /* Text color for prompt (important color) */
|
||||
font: "Roboto Bold 27"; /* Bold Roboto font, size 27 */
|
||||
}
|
||||
|
||||
listview {
|
||||
layout: vertical; /* Vertical layout for list items */
|
||||
padding: 10px; /* Padding inside the list view */
|
||||
spacing: 20px; /* Space between items in the list */
|
||||
columns: 8; /* Maximum 8 items per row */
|
||||
dynamic: true; /* Allows the list to dynamically adjust */
|
||||
orientation: horizontal; /* Horizontal orientation for list items */
|
||||
}
|
||||
|
||||
inputbar-box {
|
||||
children: [dummy, inputbar, dummy]; /* Input bar is centered with dummy placeholders */
|
||||
orientation: horizontal; /* Horizontal layout for input bar */
|
||||
expand: false; /* Does not expand to fill the space */
|
||||
}
|
||||
|
||||
inputbar {
|
||||
children: [textbox-prompt, entry]; /* Contains a prompt and an entry field */
|
||||
margin: 0px; /* No margin around the input bar */
|
||||
background-color: @primary; /* Background color set to the primary color */
|
||||
border: 4px; /* Border thickness around the input bar */
|
||||
border-color: @primary; /* Border color matches the primary color */
|
||||
border-radius: 8px; /* Rounded corners for the input bar */
|
||||
}
|
||||
|
||||
textbox-prompt {
|
||||
text-color: @background; /* Text color inside prompt matches the background color */
|
||||
horizontal-align: 0.5; /* Horizontally centered */
|
||||
vertical-align: 0.5; /* Vertically centered */
|
||||
expand: false; /* Does not expand to fill available space */
|
||||
}
|
||||
|
||||
entry {
|
||||
expand: false; /* Entry field does not expand */
|
||||
padding: 8px; /* Padding inside the entry field */
|
||||
margin: -6px; /* Negative margin to position entry properly */
|
||||
horizontal-align: 0; /* Left-aligned text inside the entry field */
|
||||
width: 300; /* Fixed width for the entry field */
|
||||
background-color: @background; /* Entry background color matches the global background */
|
||||
border: 6px; /* Border thickness around the entry field */
|
||||
border-color: @primary; /* Border color matches the primary color */
|
||||
border-radius: 8px; /* Rounded corners for the entry field */
|
||||
cursor: text; /* Cursor changes to text input cursor inside the entry field */
|
||||
}
|
||||
|
||||
element {
|
||||
children: [dummy, element-box, dummy]; /* Contains an element box with dummy placeholders */
|
||||
padding: 5px; /* Padding around the element */
|
||||
orientation: vertical; /* Vertical layout for element content */
|
||||
border: 0px; /* No border around the element */
|
||||
border-radius: 16px; /* Rounded corners for the element */
|
||||
background-color: transparent; /* Transparent background */
|
||||
width: 100px; /* Width of each element */
|
||||
height: 50px; /* Height of each element */
|
||||
}
|
||||
|
||||
element selected {
|
||||
background-color: @primary; /* Background color of the element when selected */
|
||||
}
|
||||
|
||||
element-box {
|
||||
children: [element-icon, element-text]; /* Element box contains an icon and text */
|
||||
orientation: vertical; /* Vertical layout for icon and text */
|
||||
expand: false; /* Does not expand to fill available space */
|
||||
cursor: pointer; /* Cursor changes to a pointer when hovering over the element */
|
||||
}
|
||||
|
||||
element-icon {
|
||||
padding: 10px; /* Padding inside the icon */
|
||||
cursor: inherit; /* Inherits cursor style from the parent */
|
||||
size: 33%; /* Icon size is set to 33% of the parent element */
|
||||
margin: 10px; /* Margin around the icon */
|
||||
}
|
||||
|
||||
element-text {
|
||||
horizontal-align: 0.5; /* Horizontally center-aligns the text */
|
||||
cursor: inherit; /* Inherits cursor style from the parent */
|
||||
text-color: @text-color; /* Text color for element text */
|
||||
}
|
||||
|
||||
element-text selected {
|
||||
text-color: @text-color-selected; /* Text color when the element is selected */
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 133 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 197 KiB |
@@ -1,169 +0,0 @@
|
||||
download = """
|
||||
\b
|
||||
\b\bExamples:
|
||||
# Basic download by title
|
||||
fastanime anilist download -t "Attack on Titan"
|
||||
\b
|
||||
# Download specific episodes
|
||||
fastanime anilist download -t "One Piece" --episode-range "1-10"
|
||||
\b
|
||||
# Download single episode
|
||||
fastanime anilist download -t "Death Note" --episode-range "1"
|
||||
\b
|
||||
# Download multiple specific episodes
|
||||
fastanime anilist download -t "Naruto" --episode-range "1,5,10"
|
||||
\b
|
||||
# Download with quality preference
|
||||
fastanime anilist download -t "Death Note" --quality 1080 --episode-range "1-5"
|
||||
\b
|
||||
# Download with multiple filters
|
||||
fastanime anilist download -g Action -T Isekai --score-greater 80 --status RELEASING
|
||||
\b
|
||||
# Download with concurrent downloads
|
||||
fastanime anilist download -t "Demon Slayer" --episode-range "1-5" --max-concurrent 3
|
||||
\b
|
||||
# Force redownload existing episodes
|
||||
fastanime anilist download -t "Your Name" --episode-range "1" --force-redownload
|
||||
\b
|
||||
# Download from a specific season and year
|
||||
fastanime anilist download --season WINTER --year 2024 -s POPULARITY_DESC
|
||||
\b
|
||||
# Download with genre filtering
|
||||
fastanime anilist download -g Action -g Adventure --score-greater 75
|
||||
\b
|
||||
# Download only completed series
|
||||
fastanime anilist download -g Fantasy --status FINISHED --score-greater 75
|
||||
\b
|
||||
# Download movies only
|
||||
fastanime anilist download -F MOVIE -s SCORE_DESC --quality best
|
||||
"""
|
||||
|
||||
|
||||
search = """
|
||||
\b
|
||||
\b\bExamples:
|
||||
# Basic search by title
|
||||
fastanime anilist search -t "Attack on Titan"
|
||||
\b
|
||||
# Search with multiple filters
|
||||
fastanime anilist search -g Action -T Isekai --score-greater 75 --status RELEASING
|
||||
\b
|
||||
# Get anime with the tag of isekai
|
||||
fastanime anilist search -T isekai
|
||||
\b
|
||||
# Get anime of 2024 and sort by popularity, finished or releasing, not in your list
|
||||
fastanime anilist search -y 2024 -s POPULARITY_DESC --status RELEASING --status FINISHED --not-on-list
|
||||
\b
|
||||
# Get anime of 2024 season WINTER
|
||||
fastanime anilist search -y 2024 --season WINTER
|
||||
\b
|
||||
# Get anime genre action and tag isekai,magic
|
||||
fastanime anilist search -g Action -T Isekai -T Magic
|
||||
\b
|
||||
# Get anime of 2024 thats finished airing
|
||||
fastanime anilist search -y 2024 -S FINISHED
|
||||
\b
|
||||
# Get the most favourite anime movies
|
||||
fastanime anilist search -f MOVIE -s FAVOURITES_DESC
|
||||
\b
|
||||
# Search with score and popularity filters
|
||||
fastanime anilist search --score-greater 80 --popularity-greater 50000
|
||||
\b
|
||||
# Search excluding certain genres and tags
|
||||
fastanime anilist search --genres-not Ecchi --tags-not "Hentai"
|
||||
\b
|
||||
# Search with date ranges (YYYYMMDD format)
|
||||
fastanime anilist search --start-date-greater 20200101 --start-date-lesser 20241231
|
||||
\b
|
||||
# Get only TV series, exclude certain statuses
|
||||
fastanime anilist search -f TV --status-not CANCELLED --status-not HIATUS
|
||||
\b
|
||||
# Paginated search with custom page size
|
||||
fastanime anilist search -g Action --page 2 --per-page 25
|
||||
\b
|
||||
# Search for manga specifically
|
||||
fastanime anilist search --media-type MANGA -g Fantasy
|
||||
\b
|
||||
# Complex search with multiple criteria
|
||||
fastanime anilist search -t "demon" -g Action -g Supernatural --score-greater 70 --year 2020 -s SCORE_DESC
|
||||
\b
|
||||
# Dump search results as JSON instead of interactive mode
|
||||
fastanime anilist search -g Action --dump-json
|
||||
"""
|
||||
|
||||
|
||||
main = """
|
||||
\b
|
||||
\b\bExamples:
|
||||
# ---- search ----
|
||||
\b
|
||||
# Basic search by title
|
||||
fastanime anilist search -t "Attack on Titan"
|
||||
\b
|
||||
# Search with multiple filters
|
||||
fastanime anilist search -g Action -T Isekai --score-greater 75 --status RELEASING
|
||||
\b
|
||||
# Get anime with the tag of isekai
|
||||
fastanime anilist search -T isekai
|
||||
\b
|
||||
# Get anime of 2024 and sort by popularity, finished or releasing, not in your list
|
||||
fastanime anilist search -y 2024 -s POPULARITY_DESC --status RELEASING --status FINISHED --not-on-list
|
||||
\b
|
||||
# Get anime of 2024 season WINTER
|
||||
fastanime anilist search -y 2024 --season WINTER
|
||||
\b
|
||||
# Get anime genre action and tag isekai,magic
|
||||
fastanime anilist search -g Action -T Isekai -T Magic
|
||||
\b
|
||||
# Get anime of 2024 thats finished airing
|
||||
fastanime anilist search -y 2024 -S FINISHED
|
||||
\b
|
||||
# Get the most favourite anime movies
|
||||
fastanime anilist search -f MOVIE -s FAVOURITES_DESC
|
||||
\b
|
||||
# Search with score and popularity filters
|
||||
fastanime anilist search --score-greater 80 --popularity-greater 50000
|
||||
\b
|
||||
# Search excluding certain genres and tags
|
||||
fastanime anilist search --genres-not Ecchi --tags-not "Hentai"
|
||||
\b
|
||||
# Search with date ranges (YYYYMMDD format)
|
||||
fastanime anilist search --start-date-greater 20200101 --start-date-lesser 20241231
|
||||
\b
|
||||
# Get only TV series, exclude certain statuses
|
||||
fastanime anilist search -f TV --status-not CANCELLED --status-not HIATUS
|
||||
\b
|
||||
# Paginated search with custom page size
|
||||
fastanime anilist search -g Action --page 2 --per-page 25
|
||||
\b
|
||||
# Search for manga specifically
|
||||
fastanime anilist search --media-type MANGA -g Fantasy
|
||||
\b
|
||||
# Complex search with multiple criteria
|
||||
fastanime anilist search -t "demon" -g Action -g Supernatural --score-greater 70 --year 2020 -s SCORE_DESC
|
||||
\b
|
||||
# Dump search results as JSON instead of interactive mode
|
||||
fastanime anilist search -g Action --dump-json
|
||||
\b
|
||||
# ---- login ----
|
||||
\b
|
||||
# To sign in just run
|
||||
fastanime anilist login
|
||||
\b
|
||||
# To view your login status
|
||||
fastanime anilist login --status
|
||||
\b
|
||||
# To erase login data
|
||||
fastanime anilist login --erase
|
||||
\b
|
||||
# ---- notifier ----
|
||||
\b
|
||||
# basic form
|
||||
fastanime anilist notifier
|
||||
\b
|
||||
# with logging to stdout
|
||||
fastanime --log anilist notifier
|
||||
\b
|
||||
# with logging to a file. stored in the same place as your config
|
||||
fastanime --log-file anilist notifier
|
||||
"""
|
||||
@@ -1,62 +0,0 @@
|
||||
import click
|
||||
from fastanime.core.config import AppConfig
|
||||
from fastanime.core.exceptions import FastAnimeError
|
||||
from fastanime.libs.media_api.params import MediaSearchParams
|
||||
|
||||
|
||||
@click.command(help="Queue episodes for the background worker to download.")
|
||||
@click.option(
|
||||
"--title", "-t", required=True, multiple=True, help="Anime title to queue."
|
||||
)
|
||||
@click.option(
|
||||
"--episode-range", "-r", required=True, help="Range of episodes (e.g., '1-10')."
|
||||
)
|
||||
@click.pass_obj
|
||||
def queue(config: AppConfig, title: tuple, episode_range: str):
|
||||
"""
|
||||
Searches for an anime and adds the specified episodes to the download queue.
|
||||
The background worker must be running for the downloads to start.
|
||||
"""
|
||||
from fastanime.cli.service.download.service import DownloadService
|
||||
from fastanime.cli.service.feedback import FeedbackService
|
||||
from fastanime.cli.service.registry import MediaRegistryService
|
||||
from fastanime.cli.utils.parser import parse_episode_range
|
||||
from fastanime.libs.media_api.api import create_api_client
|
||||
from fastanime.libs.provider.anime.provider import create_provider
|
||||
|
||||
feedback = FeedbackService(config)
|
||||
media_api = create_api_client(config.general.media_api, config)
|
||||
provider = create_provider(config.general.provider)
|
||||
registry = MediaRegistryService(config.general.media_api, config.media_registry)
|
||||
download_service = DownloadService(config, registry, media_api, provider)
|
||||
|
||||
for anime_title in title:
|
||||
try:
|
||||
feedback.info(f"Searching for '{anime_title}'...")
|
||||
search_result = media_api.search_media(
|
||||
MediaSearchParams(query=anime_title, per_page=1)
|
||||
)
|
||||
|
||||
if not search_result or not search_result.media:
|
||||
feedback.warning(f"Could not find '{anime_title}' on AniList.")
|
||||
continue
|
||||
|
||||
media_item = search_result.media[0]
|
||||
available_episodes = [str(i + 1) for i in range(media_item.episodes or 0)]
|
||||
episodes_to_queue = list(
|
||||
parse_episode_range(episode_range, available_episodes)
|
||||
)
|
||||
|
||||
queued_count = 0
|
||||
for ep in episodes_to_queue:
|
||||
if download_service.add_to_queue(media_item, ep):
|
||||
queued_count += 1
|
||||
|
||||
feedback.success(
|
||||
f"Successfully queued {queued_count} episodes for '{media_item.title.english}'."
|
||||
)
|
||||
|
||||
except FastAnimeError as e:
|
||||
feedback.error(f"Failed to queue '{anime_title}'", str(e))
|
||||
except Exception as e:
|
||||
feedback.error("An unexpected error occurred", str(e))
|
||||
@@ -1,31 +0,0 @@
|
||||
"""
|
||||
Example usage for the registry command
|
||||
"""
|
||||
|
||||
main = """
|
||||
|
||||
Examples:
|
||||
# Sync with remote AniList
|
||||
fastanime registry sync --upload --download
|
||||
|
||||
# Show detailed registry statistics
|
||||
fastanime registry stats --detailed
|
||||
|
||||
# Search local registry
|
||||
fastanime registry search "attack on titan"
|
||||
|
||||
# Export registry to JSON
|
||||
fastanime registry export --format json --output backup.json
|
||||
|
||||
# Import from backup
|
||||
fastanime registry import backup.json
|
||||
|
||||
# Clean up orphaned entries
|
||||
fastanime registry clean --dry-run
|
||||
|
||||
# Create full backup
|
||||
fastanime registry backup --compress
|
||||
|
||||
# Restore from backup
|
||||
fastanime registry restore backup.tar.gz
|
||||
"""
|
||||
@@ -1,160 +0,0 @@
|
||||
"""Update command for FastAnime CLI."""
|
||||
|
||||
import sys
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import click
|
||||
from rich import print
|
||||
from rich.console import Console
|
||||
from rich.markdown import Markdown
|
||||
|
||||
from ..utils.update import check_for_updates, update_app
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...core.config import AppConfig
|
||||
|
||||
|
||||
@click.command(
|
||||
help="Update FastAnime to the latest version",
|
||||
short_help="Update FastAnime",
|
||||
epilog="""
|
||||
\b
|
||||
\b\bExamples:
|
||||
# Check for updates and update if available
|
||||
fastanime update
|
||||
\b
|
||||
# Force update even if already up to date
|
||||
fastanime update --force
|
||||
\b
|
||||
# Only check for updates without updating
|
||||
fastanime update --check-only
|
||||
\b
|
||||
# Show release notes for the latest version
|
||||
fastanime update --release-notes
|
||||
""",
|
||||
)
|
||||
@click.option(
|
||||
"--force",
|
||||
"-f",
|
||||
is_flag=True,
|
||||
help="Force update even if already up to date",
|
||||
)
|
||||
@click.option(
|
||||
"--check-only",
|
||||
"-c",
|
||||
is_flag=True,
|
||||
help="Only check for updates without updating",
|
||||
)
|
||||
@click.option(
|
||||
"--release-notes",
|
||||
"-r",
|
||||
is_flag=True,
|
||||
help="Show release notes for the latest version",
|
||||
)
|
||||
@click.pass_context
|
||||
@click.pass_obj
|
||||
def update(
|
||||
config: "AppConfig",
|
||||
ctx: click.Context,
|
||||
force: bool,
|
||||
check_only: bool,
|
||||
release_notes: bool,
|
||||
) -> None:
|
||||
"""
|
||||
Update FastAnime to the latest version.
|
||||
|
||||
This command checks for available updates and optionally updates
|
||||
the application to the latest version from the configured sources
|
||||
(pip, uv, pipx, git, or nix depending on installation method).
|
||||
|
||||
Args:
|
||||
config: The application configuration object
|
||||
ctx: The click context containing CLI options
|
||||
force: Whether to force update even if already up to date
|
||||
check_only: Whether to only check for updates without updating
|
||||
release_notes: Whether to show release notes for the latest version
|
||||
"""
|
||||
try:
|
||||
if release_notes:
|
||||
print("[cyan]Fetching latest release notes...[/]")
|
||||
is_latest, release_json = check_for_updates()
|
||||
|
||||
if not release_json:
|
||||
print(
|
||||
"[yellow]Could not fetch release information. Please check your internet connection.[/]"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
version = release_json.get("tag_name", "unknown")
|
||||
release_name = release_json.get("name", version)
|
||||
release_body = release_json.get("body", "No release notes available.")
|
||||
published_at = release_json.get("published_at", "unknown")
|
||||
|
||||
console = Console()
|
||||
|
||||
print(f"[bold cyan]Release: {release_name}[/]")
|
||||
print(f"[dim]Version: {version}[/]")
|
||||
print(f"[dim]Published: {published_at}[/]")
|
||||
print()
|
||||
|
||||
# Display release notes as markdown if available
|
||||
if release_body.strip():
|
||||
markdown = Markdown(release_body)
|
||||
console.print(markdown)
|
||||
else:
|
||||
print("[dim]No release notes available for this version.[/]")
|
||||
|
||||
return
|
||||
|
||||
elif check_only:
|
||||
print("[cyan]Checking for updates...[/]")
|
||||
is_latest, release_json = check_for_updates()
|
||||
|
||||
if not release_json:
|
||||
print(
|
||||
"[yellow]Could not check for updates. Please check your internet connection.[/]"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
if is_latest:
|
||||
print("[green]FastAnime is up to date![/]")
|
||||
print(
|
||||
f"[dim]Current version: {release_json.get('tag_name', 'unknown')}[/]"
|
||||
)
|
||||
else:
|
||||
latest_version = release_json.get("tag_name", "unknown")
|
||||
print(f"[yellow]Update available: {latest_version}[/]")
|
||||
print("[dim]Run 'fastanime update' to update[/]")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("[cyan]Checking for updates and updating if necessary...[/]")
|
||||
success, release_json = update_app(force=force)
|
||||
|
||||
if not release_json:
|
||||
print(
|
||||
"[red]Could not check for updates. Please check your internet connection.[/]"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
if success:
|
||||
latest_version = release_json.get("tag_name", "unknown")
|
||||
print(f"[green]Successfully updated to version {latest_version}![/]")
|
||||
else:
|
||||
if force:
|
||||
print(
|
||||
"[red]Update failed. Please check the error messages above.[/]"
|
||||
)
|
||||
sys.exit(1)
|
||||
# If not forced and update failed, it might be because already up to date
|
||||
# The update_app function already prints appropriate messages
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n[yellow]Update cancelled by user.[/]")
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"[red]An error occurred during update: {e}[/]")
|
||||
# Get trace option from parent context
|
||||
trace = ctx.parent.params.get("trace", False) if ctx.parent else False
|
||||
if trace:
|
||||
raise
|
||||
sys.exit(1)
|
||||
@@ -1,4 +0,0 @@
|
||||
from .generate import generate_config_ini_from_app_model
|
||||
from .loader import ConfigLoader
|
||||
|
||||
__all__ = ["ConfigLoader", "generate_config_ini_from_app_model"]
|
||||
@@ -1,83 +0,0 @@
|
||||
import textwrap
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
|
||||
from ...core.config import AppConfig
|
||||
from ...core.constants import APP_ASCII_ART, DISCORD_INVITE, PROJECT_NAME, REPO_HOME
|
||||
|
||||
# The header for the config file.
|
||||
config_asci = "\n".join(
|
||||
[f"# {line}" for line in APP_ASCII_ART.read_text(encoding="utf-8").split()]
|
||||
)
|
||||
CONFIG_HEADER = f"""
|
||||
# ==============================================================================
|
||||
#
|
||||
{config_asci}
|
||||
#
|
||||
# ==============================================================================
|
||||
# This file was auto-generated from the application's configuration model.
|
||||
# You can modify these values to customize the behavior of FastAnime.
|
||||
# For path-based options, you can use '~' for your home directory.
|
||||
""".lstrip()
|
||||
|
||||
CONFIG_FOOTER = f"""
|
||||
# ==============================================================================
|
||||
#
|
||||
# HOPE YOU ENJOY {PROJECT_NAME} AND BE SURE TO STAR THE PROJECT ON GITHUB
|
||||
# {REPO_HOME}
|
||||
#
|
||||
# Also join the discord server
|
||||
# where the anime tech community lives :)
|
||||
# {DISCORD_INVITE}
|
||||
#
|
||||
# ==============================================================================
|
||||
""".lstrip()
|
||||
|
||||
|
||||
def generate_config_ini_from_app_model(app_model: AppConfig) -> str:
|
||||
"""Generate a configuration file content from a Pydantic model."""
|
||||
|
||||
model_schema = AppConfig.model_json_schema(mode="serialization")
|
||||
app_model_dict = app_model.model_dump()
|
||||
config_ini_content = [CONFIG_HEADER]
|
||||
|
||||
for section_name, section_dict in app_model_dict.items():
|
||||
section_ref = model_schema["properties"][section_name].get("$ref")
|
||||
if not section_ref:
|
||||
continue
|
||||
|
||||
section_class_name = section_ref.split("/")[-1]
|
||||
section_schema = model_schema["$defs"][section_class_name]
|
||||
section_comment = section_schema.get("description", "")
|
||||
|
||||
config_ini_content.append(f"\n#\n# {section_comment}\n#")
|
||||
config_ini_content.append(f"[{section_name}]")
|
||||
|
||||
for field_name, field_value in section_dict.items():
|
||||
field_properties = section_schema.get("properties", {}).get(field_name, {})
|
||||
description = field_properties.get("description", "")
|
||||
|
||||
if description:
|
||||
wrapped_comment = textwrap.fill(
|
||||
description,
|
||||
width=78,
|
||||
initial_indent="# ",
|
||||
subsequent_indent="# ",
|
||||
)
|
||||
config_ini_content.append(f"\n{wrapped_comment}")
|
||||
|
||||
if isinstance(field_value, bool):
|
||||
value_str = str(field_value).lower()
|
||||
elif isinstance(field_value, Path):
|
||||
value_str = str(field_value)
|
||||
elif field_value is None:
|
||||
value_str = ""
|
||||
elif isinstance(field_value, Enum):
|
||||
value_str = field_value.value
|
||||
else:
|
||||
value_str = str(field_value)
|
||||
|
||||
config_ini_content.append(f"{field_name} = {value_str}")
|
||||
|
||||
config_ini_content.extend(["\n", CONFIG_FOOTER])
|
||||
return "\n".join(config_ini_content)
|
||||
@@ -1,85 +0,0 @@
|
||||
from enum import Enum
|
||||
from typing import Dict, Optional, Union
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from ...libs.media_api.params import MediaSearchParams, UserMediaListSearchParams
|
||||
from ...libs.media_api.types import MediaItem, PageInfo
|
||||
from ...libs.provider.anime.types import Anime, SearchResults, Server
|
||||
|
||||
|
||||
# TODO: is internal directive a good name
|
||||
class InternalDirective(Enum):
|
||||
MAIN = "MAIN"
|
||||
|
||||
BACK = "BACK"
|
||||
|
||||
BACKX2 = "BACKX2"
|
||||
|
||||
BACKX3 = "BACKX3"
|
||||
|
||||
BACKX4 = "BACKX4"
|
||||
|
||||
EXIT = "EXIT"
|
||||
|
||||
CONFIG_EDIT = "CONFIG_EDIT"
|
||||
|
||||
RELOAD = "RELOAD"
|
||||
|
||||
|
||||
class MenuName(Enum):
|
||||
MAIN = "MAIN"
|
||||
AUTH = "AUTH"
|
||||
EPISODES = "EPISODES"
|
||||
RESULTS = "RESULTS"
|
||||
SERVERS = "SERVERS"
|
||||
WATCH_HISTORY = "WATCH_HISTORY"
|
||||
PROVIDER_SEARCH = "PROVIDER_SEARCH"
|
||||
PLAYER_CONTROLS = "PLAYER_CONTROLS"
|
||||
USER_MEDIA_LIST = "USER_MEDIA_LIST"
|
||||
SESSION_MANAGEMENT = "SESSION_MANAGEMENT"
|
||||
MEDIA_ACTIONS = "MEDIA_ACTIONS"
|
||||
DOWNLOADS = "DOWNLOADS"
|
||||
DYNAMIC_SEARCH = "DYNAMIC_SEARCH"
|
||||
MEDIA_REVIEW = "MEDIA_REVIEW"
|
||||
MEDIA_CHARACTERS = "MEDIA_CHARACTERS"
|
||||
MEDIA_AIRING_SCHEDULE = "MEDIA_AIRING_SCHEDULE"
|
||||
PLAY_DOWNLOADS = "PLAY_DOWNLOADS"
|
||||
DOWNLOADS_PLAYER_CONTROLS = "DOWNLOADS_PLAYER_CONTROLS"
|
||||
DOWNLOAD_EPISODES = "DOWNLOAD_EPISODES"
|
||||
|
||||
|
||||
class StateModel(BaseModel):
|
||||
model_config = ConfigDict(frozen=True)
|
||||
|
||||
|
||||
class MediaApiState(StateModel):
|
||||
search_result: Optional[Dict[int, MediaItem]] = None
|
||||
search_params: Optional[Union[MediaSearchParams, UserMediaListSearchParams]] = None
|
||||
page_info: Optional[PageInfo] = None
|
||||
media_id: Optional[int] = None
|
||||
|
||||
@property
|
||||
def media_item(self) -> Optional[MediaItem]:
|
||||
if self.search_result and self.media_id:
|
||||
return self.search_result[self.media_id]
|
||||
|
||||
|
||||
class ProviderState(StateModel):
|
||||
search_results: Optional[SearchResults] = None
|
||||
anime: Optional[Anime] = None
|
||||
episode: Optional[str] = None
|
||||
servers: Optional[Dict[str, Server]] = None
|
||||
server_name: Optional[str] = None
|
||||
start_time: Optional[str] = None
|
||||
|
||||
@property
|
||||
def server(self) -> Optional[Server]:
|
||||
if self.servers and self.server_name:
|
||||
return self.servers[self.server_name]
|
||||
|
||||
|
||||
class State(StateModel):
|
||||
menu_name: MenuName
|
||||
provider: ProviderState = Field(default_factory=ProviderState)
|
||||
media_api: MediaApiState = Field(default_factory=MediaApiState)
|
||||
@@ -1,103 +0,0 @@
|
||||
from contextlib import contextmanager
|
||||
from typing import Optional
|
||||
|
||||
import click
|
||||
from rich.console import Console
|
||||
from rich.progress import (
|
||||
BarColumn,
|
||||
Progress,
|
||||
SpinnerColumn,
|
||||
TaskProgressColumn,
|
||||
TextColumn,
|
||||
)
|
||||
|
||||
from ....core.config import AppConfig
|
||||
|
||||
console = Console()
|
||||
|
||||
|
||||
class FeedbackService:
|
||||
"""Centralized manager for user feedback in interactive menus."""
|
||||
|
||||
def __init__(self, config: AppConfig):
|
||||
self.config = config
|
||||
|
||||
def success(self, message: str, details: Optional[str] = None) -> None:
|
||||
"""Show a success message with optional details."""
|
||||
icon = "✅ " if self.config.general.icons else ""
|
||||
main_msg = f"[bold green]{icon}{message}[/bold green]"
|
||||
|
||||
if details:
|
||||
console.print(f"{main_msg}\n[dim]{details}[/dim]")
|
||||
else:
|
||||
console.print(main_msg)
|
||||
|
||||
def error(self, message: str, details: Optional[str] = None) -> None:
|
||||
"""Show an error message with optional details."""
|
||||
icon = "❌ " if self.config.general.icons else ""
|
||||
main_msg = f"[bold red]{icon}Error: {message}[/bold red]"
|
||||
|
||||
if details:
|
||||
console.print(f"{main_msg}\n[dim]{details}[/dim]")
|
||||
else:
|
||||
console.print(main_msg)
|
||||
click.pause("Enter to continue...")
|
||||
|
||||
def warning(self, message: str, details: Optional[str] = None) -> None:
|
||||
"""Show a warning message with optional details."""
|
||||
icon = "⚠️ " if self.config.general.icons else ""
|
||||
main_msg = f"[bold yellow]{icon}Warning: {message}[/bold yellow]"
|
||||
|
||||
if details:
|
||||
console.print(f"{main_msg}\n[dim]{details}[/dim]")
|
||||
else:
|
||||
console.print(main_msg)
|
||||
|
||||
def info(self, message: str, details: Optional[str] = None) -> None:
|
||||
"""Show an informational message with optional details."""
|
||||
icon = "" if self.config.general.icons else ""
|
||||
main_msg = f"[bold blue]{icon}{message}[/bold blue]"
|
||||
|
||||
if details:
|
||||
console.print(f"{main_msg}\n[dim]{details}[/dim]")
|
||||
else:
|
||||
console.print(main_msg)
|
||||
# time.sleep(5)
|
||||
|
||||
@contextmanager
|
||||
def progress(
|
||||
self,
|
||||
message: str,
|
||||
total: Optional[float] = None,
|
||||
transient: bool = False,
|
||||
auto_add_task: bool = True,
|
||||
success_msg: Optional[str] = None,
|
||||
error_msg: Optional[str] = None,
|
||||
):
|
||||
"""Context manager for operations with loading indicator and result feedback."""
|
||||
with Progress(
|
||||
SpinnerColumn(self.config.general.preferred_spinner),
|
||||
TextColumn(f"[cyan]{message}..."),
|
||||
BarColumn(),
|
||||
TaskProgressColumn(),
|
||||
transient=transient,
|
||||
console=console,
|
||||
) as progress:
|
||||
task_id = progress.add_task("", total=total)
|
||||
try:
|
||||
yield task_id, progress
|
||||
if success_msg:
|
||||
self.success(success_msg)
|
||||
except Exception as e:
|
||||
error_details = str(e) if str(e) else None
|
||||
final_error_msg = error_msg or "Operation failed"
|
||||
self.error(final_error_msg, error_details)
|
||||
raise
|
||||
|
||||
def pause_for_user(self, message: str = "Press Enter to continue") -> None:
|
||||
"""Pause execution and wait for user input."""
|
||||
icon = "⏸️ " if self.config.general.icons else ""
|
||||
click.pause(f"{icon}{message}...")
|
||||
|
||||
def clear_console(self):
|
||||
console.clear()
|
||||
@@ -1,78 +0,0 @@
|
||||
import json
|
||||
import logging
|
||||
from typing import Set
|
||||
|
||||
from fastanime.core.constants import APP_CACHE_DIR
|
||||
from fastanime.libs.media_api.base import BaseApiClient
|
||||
|
||||
try:
|
||||
import plyer
|
||||
|
||||
PLYER_AVAILABLE = True
|
||||
except ImportError:
|
||||
PLYER_AVAILABLE = False
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
SEEN_NOTIFICATIONS_CACHE = APP_CACHE_DIR / "seen_notifications.json"
|
||||
|
||||
|
||||
class NotificationService:
|
||||
def __init__(self, media_api: BaseApiClient):
|
||||
self.media_api = media_api
|
||||
self._seen_ids: Set[int] = self._load_seen_ids()
|
||||
|
||||
def _load_seen_ids(self) -> Set[int]:
|
||||
if not SEEN_NOTIFICATIONS_CACHE.exists():
|
||||
return set()
|
||||
try:
|
||||
with open(SEEN_NOTIFICATIONS_CACHE, "r") as f:
|
||||
return set(json.load(f))
|
||||
except (json.JSONDecodeError, IOError):
|
||||
return set()
|
||||
|
||||
def _save_seen_ids(self):
|
||||
try:
|
||||
with open(SEEN_NOTIFICATIONS_CACHE, "w") as f:
|
||||
json.dump(list(self._seen_ids), f)
|
||||
except IOError:
|
||||
logger.error("Failed to save seen notifications cache.")
|
||||
|
||||
def check_and_display_notifications(self):
|
||||
if not PLYER_AVAILABLE:
|
||||
logger.warning("plyer not installed. Cannot display desktop notifications.")
|
||||
return
|
||||
|
||||
if not self.media_api.is_authenticated():
|
||||
logger.info("Not authenticated, skipping notification check.")
|
||||
return
|
||||
|
||||
logger.info("Checking for new notifications...")
|
||||
notifications = self.media_api.get_notifications()
|
||||
|
||||
if not notifications:
|
||||
logger.info("No new notifications found.")
|
||||
return
|
||||
|
||||
new_notifications = [n for n in notifications if n.id not in self._seen_ids]
|
||||
|
||||
if not new_notifications:
|
||||
logger.info("No unseen notifications found.")
|
||||
return
|
||||
|
||||
for notif in new_notifications:
|
||||
title = notif.media.title.english or notif.media.title.romaji
|
||||
message = f"Episode {notif.episode} of {title} has aired!"
|
||||
|
||||
try:
|
||||
plyer.notification.notify(
|
||||
title="FastAnime: New Episode",
|
||||
message=message,
|
||||
app_name="FastAnime",
|
||||
timeout=20,
|
||||
)
|
||||
logger.info(f"Displayed notification: {message}")
|
||||
self._seen_ids.add(notif.id)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to display notification: {e}")
|
||||
|
||||
self._save_seen_ids()
|
||||
@@ -1,61 +0,0 @@
|
||||
import logging
|
||||
import time
|
||||
|
||||
from fastanime.cli.service.download.service import DownloadService
|
||||
from fastanime.cli.service.notification.service import NotificationService
|
||||
from fastanime.core.config.model import WorkerConfig
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BackgroundWorkerService:
|
||||
def __init__(
|
||||
self,
|
||||
config: WorkerConfig,
|
||||
notification_service: NotificationService,
|
||||
download_service: DownloadService,
|
||||
):
|
||||
self.config = config
|
||||
self.notification_service = notification_service
|
||||
self.download_service = download_service
|
||||
self.running = True
|
||||
|
||||
def run(self):
|
||||
logger.info("Background worker started.")
|
||||
last_notification_check = 0
|
||||
last_download_check = 0
|
||||
|
||||
notification_interval_sec = self.config.notification_check_interval * 60
|
||||
download_interval_sec = self.config.download_check_interval * 60
|
||||
self.download_service.start()
|
||||
|
||||
try:
|
||||
while self.running:
|
||||
current_time = time.time()
|
||||
|
||||
# Check for notifications
|
||||
if current_time - last_notification_check > notification_interval_sec:
|
||||
try:
|
||||
self.notification_service.check_and_display_notifications()
|
||||
except Exception as e:
|
||||
logger.error(f"Error during notification check: {e}")
|
||||
last_notification_check = current_time
|
||||
|
||||
# Process download queue
|
||||
if current_time - last_download_check > download_interval_sec:
|
||||
try:
|
||||
self.download_service.resume_unfinished_downloads()
|
||||
except Exception as e:
|
||||
logger.error(f"Error during download queue processing: {e}")
|
||||
last_download_check = current_time
|
||||
|
||||
# Sleep for a short interval to prevent high CPU usage
|
||||
time.sleep(30) # Sleep for 30 seconds before next check cycle
|
||||
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Background worker stopped by user.")
|
||||
self.stop()
|
||||
|
||||
def stop(self):
|
||||
self.running = False
|
||||
logger.info("Background worker shutting down.")
|
||||
@@ -1,7 +0,0 @@
|
||||
"""
|
||||
Core utilities for FastAnime application.
|
||||
|
||||
This module provides various utility classes and functions used throughout
|
||||
the FastAnime application, including concurrency management, file operations,
|
||||
and other common functionality.
|
||||
"""
|
||||
@@ -1,27 +0,0 @@
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
|
||||
def is_running_in_termux():
|
||||
# Check environment variables
|
||||
if os.environ.get("TERMUX_VERSION") is not None:
|
||||
return True
|
||||
|
||||
# Check Python installation path
|
||||
if sys.prefix.startswith("/data/data/com.termux/files/usr"):
|
||||
return True
|
||||
|
||||
# Check for Termux-specific binary
|
||||
if os.path.exists("/data/data/com.termux/files/usr/bin/termux-info"):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def is_running_kitty_terminal() -> bool:
|
||||
return True if os.environ.get("KITTY_WINDOW_ID") else False
|
||||
|
||||
|
||||
def has_fzf() -> bool:
|
||||
return True if shutil.which("fzf") else False
|
||||
@@ -1,3 +0,0 @@
|
||||
from .player import create_player
|
||||
|
||||
__all__ = ["create_player"]
|
||||
@@ -1,26 +0,0 @@
|
||||
import subprocess
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from ...core.config import StreamConfig
|
||||
from .params import PlayerParams
|
||||
from .types import PlayerResult
|
||||
|
||||
|
||||
class BasePlayer(ABC):
|
||||
"""
|
||||
Abstract Base Class defining the contract for all media players.
|
||||
"""
|
||||
|
||||
def __init__(self, config: StreamConfig):
|
||||
self.stream_config = config
|
||||
|
||||
@abstractmethod
|
||||
def play(self, params: PlayerParams) -> PlayerResult:
|
||||
"""
|
||||
Plays the given media URL.
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def play_with_ipc(self, params: PlayerParams, socket_path: str) -> subprocess.Popen:
|
||||
"""Stream using IPC player for enhanced features."""
|
||||
@@ -1,17 +0,0 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PlayerParams:
|
||||
url: str
|
||||
title: str
|
||||
query: str
|
||||
episode: str
|
||||
syncplay: bool = False
|
||||
subtitles: list[str] | None = None
|
||||
headers: dict[str, str] | None = None
|
||||
start_time: str | None = None
|
||||
@@ -1,38 +0,0 @@
|
||||
from ...core.config import AppConfig
|
||||
from .base import BasePlayer
|
||||
|
||||
PLAYERS = ["mpv", "vlc", "syncplay"]
|
||||
|
||||
|
||||
class PlayerFactory:
|
||||
@staticmethod
|
||||
def create(config: AppConfig) -> BasePlayer:
|
||||
"""
|
||||
Factory method to create a player instance based on its name.
|
||||
|
||||
Args:
|
||||
config: The full application configuration object.
|
||||
|
||||
Returns:
|
||||
An instance of a class that inherits from BasePlayer.
|
||||
|
||||
Raises:
|
||||
ValueError: If the player_name is not supported.
|
||||
"""
|
||||
player_name = config.stream.player
|
||||
|
||||
if player_name not in PLAYERS:
|
||||
raise ValueError(
|
||||
f"Unsupported player: '{player_name}'. Supported players are: {PLAYERS}"
|
||||
)
|
||||
|
||||
if player_name == "mpv":
|
||||
from .mpv.player import MpvPlayer
|
||||
|
||||
return MpvPlayer(config.mpv)
|
||||
raise NotImplementedError(
|
||||
f"Configuration logic for player '{player_name}' not implemented in factory."
|
||||
)
|
||||
|
||||
|
||||
create_player = PlayerFactory.create
|
||||
@@ -1,8 +0,0 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PlayerResult:
|
||||
episode: str
|
||||
stop_time: str | None = None
|
||||
total_time: str | None = None
|
||||
@@ -1,23 +0,0 @@
|
||||
from InquirerPy.prompts import FuzzyPrompt
|
||||
from rich.prompt import Confirm, Prompt
|
||||
|
||||
from ..base import BaseSelector
|
||||
|
||||
|
||||
class InquirerSelector(BaseSelector):
|
||||
def choose(self, prompt, choices, *, preview=None, header=None):
|
||||
if header:
|
||||
print(f"[bold cyan]{header}[/bold cyan]")
|
||||
return FuzzyPrompt(
|
||||
message=prompt,
|
||||
choices=choices,
|
||||
height="100%",
|
||||
border=True,
|
||||
validate=lambda result: result in choices,
|
||||
).execute()
|
||||
|
||||
def confirm(self, prompt, *, default=False):
|
||||
return Confirm.ask(prompt, default=default)
|
||||
|
||||
def ask(self, prompt, *, default=None):
|
||||
return Prompt.ask(prompt=prompt, default=default or "")
|
||||
@@ -1,47 +0,0 @@
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from ....core.config import RofiConfig
|
||||
from ..base import BaseSelector
|
||||
|
||||
|
||||
class RofiSelector(BaseSelector):
|
||||
def __init__(self, config: RofiConfig):
|
||||
self.config = config
|
||||
self.executable = shutil.which("rofi")
|
||||
if not self.executable:
|
||||
raise FileNotFoundError("rofi executable not found in PATH.")
|
||||
|
||||
def choose(self, prompt, choices, *, preview=None, header=None):
|
||||
rofi_input = "\n".join(choices)
|
||||
|
||||
args = [
|
||||
self.executable,
|
||||
"-no-config",
|
||||
"-theme",
|
||||
self.config.theme_main,
|
||||
"-p",
|
||||
prompt,
|
||||
"-i",
|
||||
"-dmenu",
|
||||
]
|
||||
result = subprocess.run(
|
||||
args,
|
||||
input=rofi_input,
|
||||
stdout=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
|
||||
if result:
|
||||
choice = result.stdout.strip()
|
||||
return choice
|
||||
|
||||
def confirm(self, prompt, *, default=False):
|
||||
# Maps directly to your existing `confirm` method
|
||||
# ... (logic from your `Rofi.confirm` method) ...
|
||||
pass
|
||||
|
||||
def ask(self, prompt, *, default=None):
|
||||
# Maps directly to your existing `ask` method
|
||||
# ... (logic from your `Rofi.ask` method) ...
|
||||
pass
|
||||
14
flake.nix
14
flake.nix
@@ -1,5 +1,5 @@
|
||||
{
|
||||
description = "FastAnime Project Flake";
|
||||
description = "Viu Project Flake";
|
||||
|
||||
inputs = {
|
||||
# The nixpkgs unstable latest commit breaks the plyer python package
|
||||
@@ -19,11 +19,11 @@
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
inherit (pkgs) lib python3Packages;
|
||||
|
||||
version = "3.0.0";
|
||||
version = "3.1.0";
|
||||
in
|
||||
{
|
||||
packages.default = python3Packages.buildPythonApplication {
|
||||
pname = "fastanime";
|
||||
pname = "viu";
|
||||
inherit version;
|
||||
pyproject = true;
|
||||
|
||||
@@ -67,13 +67,11 @@
|
||||
# Needs to be adapted for the nix derivation build
|
||||
doCheck = false;
|
||||
|
||||
pythonImportsCheck = [ "fastanime" ];
|
||||
|
||||
meta = {
|
||||
description = "Your browser anime experience from the terminal";
|
||||
homepage = "https://github.com/Benexl/FastAnime";
|
||||
changelog = "https://github.com/Benexl/FastAnime/releases/tag/v${version}";
|
||||
mainProgram = "fastanime";
|
||||
homepage = "https://github.com/Benexl/Viu";
|
||||
changelog = "https://github.com/Benexl/Viu/releases/tag/v${version}";
|
||||
mainProgram = "viu";
|
||||
license = lib.licenses.unlicense;
|
||||
maintainers = with lib.maintainers; [ theobori ];
|
||||
};
|
||||
|
||||
@@ -1,29 +1,37 @@
|
||||
[project]
|
||||
name = "fastanime"
|
||||
version = "3.0.0"
|
||||
name = "viu-media"
|
||||
version = "3.2.7"
|
||||
description = "A browser anime site experience from the terminal"
|
||||
license = "UNLICENSE"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
requires-python = ">=3.11"
|
||||
dependencies = [
|
||||
"click>=8.1.7",
|
||||
"httpx>=0.28.1",
|
||||
"inquirerpy>=0.3.4",
|
||||
"pydantic>=2.11.7",
|
||||
"rich>=13.9.2",
|
||||
"tomli-w>=1.0.0",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
fastanime = 'fastanime:Cli'
|
||||
viu = 'viu_media:Cli'
|
||||
|
||||
[project.optional-dependencies]
|
||||
standard = [
|
||||
"lxml>=6.0.0",
|
||||
"thefuzz>=0.22.1",
|
||||
"yt-dlp>=2025.7.21",
|
||||
"pycryptodomex>=3.23.0",
|
||||
"pypiwin32; sys_platform == 'win32'", # For Windows-specific functionality
|
||||
"pyobjc; sys_platform == 'darwin'", # For macOS-specific functionality
|
||||
"dbus-python; sys_platform == 'linux'", # For Linux-specific functionality (e.g., notifications),
|
||||
"plyer>=2.1.0",
|
||||
"lxml>=6.0.0"
|
||||
]
|
||||
notifications = [
|
||||
"dbus-python>=1.4.0",
|
||||
"plyer>=2.1.0",
|
||||
]
|
||||
notifications = ["plyer>=2.1.0"]
|
||||
mpv = [
|
||||
"mpv>=1.0.7",
|
||||
]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"venvPath": ".",
|
||||
"venv": ".venv",
|
||||
"pythonVersion": "3.10"
|
||||
"pythonVersion": "3.11"
|
||||
}
|
||||
|
||||
47
pytest.ini
47
pytest.ini
@@ -1,47 +0,0 @@
|
||||
[tool.pytest.ini_options]
|
||||
minversion = "6.0"
|
||||
addopts = [
|
||||
"-ra",
|
||||
"--strict-markers",
|
||||
"--strict-config",
|
||||
"--cov=fastanime.cli.interactive",
|
||||
"--cov-report=term-missing",
|
||||
"--cov-report=html:htmlcov",
|
||||
"--cov-report=xml",
|
||||
"-v",
|
||||
]
|
||||
testpaths = [
|
||||
"tests",
|
||||
]
|
||||
python_files = [
|
||||
"test_*.py",
|
||||
"*_test.py",
|
||||
]
|
||||
python_classes = [
|
||||
"Test*",
|
||||
]
|
||||
python_functions = [
|
||||
"test_*",
|
||||
]
|
||||
markers = [
|
||||
"unit: Unit tests",
|
||||
"integration: Integration tests",
|
||||
"slow: Slow running tests",
|
||||
"network: Tests requiring network access",
|
||||
"auth: Tests requiring authentication",
|
||||
]
|
||||
filterwarnings = [
|
||||
"ignore::DeprecationWarning",
|
||||
"ignore::PendingDeprecationWarning",
|
||||
]
|
||||
|
||||
# Test discovery patterns
|
||||
collect_ignore = [
|
||||
"setup.py",
|
||||
]
|
||||
|
||||
# Pytest plugins
|
||||
required_plugins = [
|
||||
"pytest-cov",
|
||||
"pytest-mock",
|
||||
]
|
||||
2
tox.ini
2
tox.ini
@@ -1,7 +1,7 @@
|
||||
[tox]
|
||||
requires =
|
||||
tox>=4
|
||||
env_list = lint, pyright, py{310,311}
|
||||
env_list = lint, pyright, py{311,312}
|
||||
|
||||
[testenv]
|
||||
description = run unit tests
|
||||
|
||||
2
fa → viu
Executable file → Normal file
2
fa → viu
Executable file → Normal file
@@ -3,4 +3,4 @@ provider_type=$1
|
||||
provider_name=$2
|
||||
[ -z "$provider_type" ] && echo "Please specify provider type" && exit
|
||||
[ -z "$provider_name" ] && echo "Please specify provider type" && exit
|
||||
uv run python -m fastanime.libs.provider.${provider_type}.${provider_name}.provider
|
||||
uv run python -m viu_media.libs.provider.${provider_type}.${provider_name}.provider
|
||||
@@ -1,8 +1,8 @@
|
||||
import sys
|
||||
|
||||
if sys.version_info < (3, 10):
|
||||
if sys.version_info < (3, 11):
|
||||
raise ImportError(
|
||||
"You are using an unsupported version of Python. Only Python versions 3.10 and above are supported by FastAnime"
|
||||
"You are using an unsupported version of Python. Only Python versions 3.10 and above are supported by Viu"
|
||||
) # noqa: F541
|
||||
|
||||
|
||||
6
viu_media/assets/defaults/ascii-art
Normal file
6
viu_media/assets/defaults/ascii-art
Normal file
@@ -0,0 +1,6 @@
|
||||
██╗░░░██╗██╗██╗░░░██╗
|
||||
██║░░░██║██║██║░░░██║
|
||||
╚██╗░██╔╝██║██║░░░██║
|
||||
░╚████╔╝░██║██║░░░██║
|
||||
░░╚██╔╝░░██║╚██████╔╝
|
||||
░░░╚═╝░░░╚═╝░╚═════╝░
|
||||
113
viu_media/assets/defaults/rofi-themes/confirm.rasi
Normal file
113
viu_media/assets/defaults/rofi-themes/confirm.rasi
Normal file
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* Rofi Theme: Viu "Tokyo Night" Confirmation
|
||||
* Author: Gemini ft Benexl
|
||||
* Description: A compact and clear modal dialog for Yes/No confirmations that displays a prompt.
|
||||
*/
|
||||
|
||||
/*****----- Configuration -----*****/
|
||||
configuration {
|
||||
font: "JetBrains Mono Nerd Font 12";
|
||||
}
|
||||
|
||||
/*****----- Global Properties -----*****/
|
||||
* {
|
||||
/* Tokyo Night Color Palette */
|
||||
bg-col: #1a1b26;
|
||||
bg-alt: #24283b;
|
||||
fg-col: #c0caf5;
|
||||
|
||||
blue: #7aa2f7;
|
||||
green: #9ece6a; /* For 'Yes' */
|
||||
red: #f7768e; /* For 'No' */
|
||||
|
||||
background-color: transparent;
|
||||
text-color: @fg-col;
|
||||
}
|
||||
|
||||
/*****----- Main Window -----*****/
|
||||
window {
|
||||
transparency: "real";
|
||||
location: center;
|
||||
anchor: center;
|
||||
fullscreen: false;
|
||||
width: 350px;
|
||||
|
||||
border: 2px;
|
||||
border-color: @blue;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
background-color: @bg-col;
|
||||
}
|
||||
|
||||
/*****----- Main Box -----*****/
|
||||
mainbox {
|
||||
children: [ inputbar, message, listview ];
|
||||
spacing: 15px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/*****----- Inputbar (Displays the -p 'prompt') -----*****/
|
||||
inputbar {
|
||||
background-color: transparent;
|
||||
text-color: @blue;
|
||||
children: [ prompt ];
|
||||
}
|
||||
|
||||
prompt {
|
||||
font: "JetBrains Mono Nerd Font Bold 14";
|
||||
horizontal-align: 0.5; /* Center the title */
|
||||
background-color: transparent;
|
||||
text-color: inherit;
|
||||
}
|
||||
|
||||
|
||||
/*****----- Message (Displays the -mesg 'Are you Sure?') -----*****/
|
||||
message {
|
||||
padding: 10px;
|
||||
margin: 5px 0px;
|
||||
border-radius: 8px;
|
||||
background-color: @bg-alt;
|
||||
text-color: @fg-col;
|
||||
}
|
||||
|
||||
textbox {
|
||||
font: "JetBrains Mono Nerd Font 12";
|
||||
horizontal-align: 0.5;
|
||||
background-color: transparent;
|
||||
text-color: inherit;
|
||||
}
|
||||
|
||||
/*****----- Listview (The Buttons) -----*****/
|
||||
listview {
|
||||
columns: 2;
|
||||
lines: 1;
|
||||
spacing: 15px;
|
||||
layout: vertical;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/*****----- Elements (Yes/No Buttons) -----*****/
|
||||
element {
|
||||
padding: 12px;
|
||||
border-radius: 8px;
|
||||
background-color: @bg-alt;
|
||||
text-color: @fg-col;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
element-text {
|
||||
font: "JetBrains Mono Nerd Font Bold 12";
|
||||
horizontal-align: 0.5;
|
||||
background-color: transparent;
|
||||
text-color: inherit;
|
||||
}
|
||||
|
||||
element normal.normal {
|
||||
background-color: @bg-alt;
|
||||
text-color: @fg-col;
|
||||
}
|
||||
|
||||
element selected.normal {
|
||||
background-color: @blue;
|
||||
text-color: @bg-col;
|
||||
}
|
||||
86
viu_media/assets/defaults/rofi-themes/input.rasi
Normal file
86
viu_media/assets/defaults/rofi-themes/input.rasi
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Rofi Theme: Viu "Tokyo Night" Input
|
||||
* Author: Gemini ft Benexl
|
||||
* Description: A compact, modern modal dialog for text input that correctly displays the prompt.
|
||||
*/
|
||||
|
||||
/*****----- Configuration -----*****/
|
||||
configuration {
|
||||
font: "JetBrains Mono Nerd Font 14";
|
||||
}
|
||||
|
||||
/*****----- Global Properties -----*****/
|
||||
* {
|
||||
/* Tokyo Night Color Palette */
|
||||
bg-col: #1a1b26ff;
|
||||
bg-alt: #24283bff;
|
||||
fg-col: #c0caf5ff;
|
||||
fg-alt: #a9b1d6ff;
|
||||
accent: #bb9af7ff;
|
||||
blue: #7aa2f7ff;
|
||||
|
||||
background-color: transparent;
|
||||
text-color: @fg-col;
|
||||
}
|
||||
|
||||
/*****----- Main Window -----*****/
|
||||
window {
|
||||
transparency: "real";
|
||||
location: center;
|
||||
anchor: center;
|
||||
fullscreen: false;
|
||||
width: 500px;
|
||||
|
||||
border: 2px;
|
||||
border-color: @blue;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
background-color: @bg-col;
|
||||
}
|
||||
|
||||
/*****----- Main Box -----*****/
|
||||
mainbox {
|
||||
children: [ message, inputbar ];
|
||||
spacing: 20px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/*****----- Message (The Main Question, uses -mesg) -----*****/
|
||||
message {
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
background-color: @bg-alt;
|
||||
text-color: @fg-col;
|
||||
}
|
||||
|
||||
textbox {
|
||||
font: "JetBrains Mono Nerd Font Bold 14";
|
||||
horizontal-align: 0.5; /* Center the prompt text */
|
||||
background-color: transparent;
|
||||
text-color: inherit;
|
||||
}
|
||||
|
||||
/*****----- Inputbar (Contains the title and entry field) -----*****/
|
||||
inputbar {
|
||||
padding: 8px 12px;
|
||||
border: 1px;
|
||||
border-radius: 6px;
|
||||
border-color: @accent;
|
||||
background-color: @bg-alt;
|
||||
spacing: 10px;
|
||||
children: [ prompt, entry ];
|
||||
}
|
||||
|
||||
/* This is the title from the -p flag */
|
||||
prompt {
|
||||
background-color: transparent;
|
||||
text-color: @accent;
|
||||
}
|
||||
|
||||
/* This is where the user types */
|
||||
entry {
|
||||
background-color: transparent;
|
||||
text-color: @fg-col;
|
||||
placeholder: "Type here...";
|
||||
placeholder-color: @fg-alt;
|
||||
}
|
||||
104
viu_media/assets/defaults/rofi-themes/main.rasi
Normal file
104
viu_media/assets/defaults/rofi-themes/main.rasi
Normal file
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* Rofi Theme: Viu "Tokyo Night" Main
|
||||
* Author: Gemini ft Benexl
|
||||
* Description: A sharp, modern, and ultra-compact theme with a Tokyo Night palette.
|
||||
*/
|
||||
|
||||
/*****----- Configuration -----*****/
|
||||
configuration {
|
||||
font: "JetBrains Mono Nerd Font 14";
|
||||
show-icons: false;
|
||||
location: 0; /* 0 = center */
|
||||
width: 50;
|
||||
yoffset: -50;
|
||||
lines: 3;
|
||||
}
|
||||
|
||||
/*****----- Global Properties -----*****/
|
||||
* {
|
||||
/* Tokyo Night Color Palette */
|
||||
bg-col: #1a1b26ff; /* Main Background */
|
||||
bg-alt: #24283bff; /* Lighter Background for elements */
|
||||
fg-col: #c0caf5ff; /* Main Foreground */
|
||||
fg-alt: #a9b1d6ff; /* Dimmer Foreground for placeholders */
|
||||
accent: #bb9af7ff; /* Magenta/Purple for accents */
|
||||
selected: #7aa2f7ff; /* Blue for selection highlight */
|
||||
|
||||
background-color: transparent;
|
||||
text-color: @fg-col;
|
||||
}
|
||||
|
||||
/*****----- Main Window -----*****/
|
||||
window {
|
||||
transparency: "real";
|
||||
background-color: @bg-col;
|
||||
border: 2px;
|
||||
border-color: @selected; /* Using blue for the main border */
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
/*****----- Main Box -----*****/
|
||||
mainbox {
|
||||
children: [ inputbar, listview ];
|
||||
spacing: 10px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/*****----- Inputbar -----*****/
|
||||
inputbar {
|
||||
background-color: @bg-alt;
|
||||
border: 1px;
|
||||
border-color: @accent; /* Using magenta for the input border */
|
||||
border-radius: 6px;
|
||||
padding: 6px 12px;
|
||||
spacing: 12px;
|
||||
children: [ prompt, entry ];
|
||||
}
|
||||
|
||||
prompt {
|
||||
background-color: transparent;
|
||||
text-color: @accent;
|
||||
}
|
||||
|
||||
entry {
|
||||
background-color: transparent;
|
||||
text-color: @fg-col;
|
||||
placeholder: "Search...";
|
||||
placeholder-color: @fg-alt;
|
||||
}
|
||||
|
||||
/*****----- List of items -----*****/
|
||||
listview {
|
||||
scrollbar: false;
|
||||
spacing: 4px;
|
||||
padding: 4px 0px;
|
||||
layout: vertical;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/*****----- Elements -----*****/
|
||||
element {
|
||||
padding: 6px 12px;
|
||||
border-radius: 6px;
|
||||
spacing: 15px;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
element-text {
|
||||
vertical-align: 0.5;
|
||||
background-color: transparent;
|
||||
text-color: inherit;
|
||||
}
|
||||
|
||||
/* Default state of elements */
|
||||
element normal.normal {
|
||||
background-color: transparent;
|
||||
text-color: @fg-col;
|
||||
}
|
||||
|
||||
/* Selected entry in the list */
|
||||
element selected.normal {
|
||||
background-color: @selected; /* Blue highlight */
|
||||
text-color: @bg-col; /* Dark text for high contrast */
|
||||
}
|
||||
109
viu_media/assets/defaults/rofi-themes/preview.rasi
Normal file
109
viu_media/assets/defaults/rofi-themes/preview.rasi
Normal file
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Rofi Theme: Viu "Tokyo Night" Horizontal Strip
|
||||
* Author: Gemini ft Benexl
|
||||
* Description: A fullscreen, horizontal, icon-centric theme for previews.
|
||||
*/
|
||||
|
||||
/*****----- Configuration -----*****/
|
||||
configuration {
|
||||
font: "JetBrains Mono Nerd Font 12";
|
||||
show-icons: true;
|
||||
}
|
||||
|
||||
/*****----- Global Properties -----*****/
|
||||
* {
|
||||
/* Tokyo Night Color Palette */
|
||||
bg-col: #1a1b26;
|
||||
bg-alt: #24283b; /* Slightly lighter for elements */
|
||||
fg-col: #c0caf5;
|
||||
fg-alt: #a9b1d6;
|
||||
|
||||
blue: #7aa2f7;
|
||||
cyan: #7dcfff;
|
||||
magenta: #bb9af7;
|
||||
|
||||
background-color: transparent;
|
||||
text-color: @fg-col;
|
||||
}
|
||||
|
||||
/*****----- Main Window -----*****/
|
||||
window {
|
||||
transparency: "real";
|
||||
background-color: @bg-col;
|
||||
fullscreen: true;
|
||||
padding: 2%;
|
||||
}
|
||||
|
||||
/*****----- Main Box -----*****/
|
||||
mainbox {
|
||||
children: [ inputbar, listview ];
|
||||
spacing: 3%;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/*****----- Inputbar -----*****/
|
||||
inputbar {
|
||||
spacing: 15px;
|
||||
padding: 12px 16px;
|
||||
border-radius: 10px;
|
||||
background-color: @bg-alt;
|
||||
text-color: @fg-col;
|
||||
margin: 0% 20%; /* Center the input bar */
|
||||
children: [ prompt, entry ];
|
||||
}
|
||||
|
||||
prompt {
|
||||
text-color: @magenta;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
entry {
|
||||
background-color: transparent;
|
||||
placeholder: "Select an option...";
|
||||
placeholder-color: @fg-alt;
|
||||
}
|
||||
|
||||
/*****----- List of items -----*****/
|
||||
listview {
|
||||
layout: horizontal;
|
||||
columns: 5;
|
||||
spacing: 20px;
|
||||
fixed-height: true;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/*****----- Elements -----*****/
|
||||
element {
|
||||
orientation: vertical;
|
||||
padding: 30px 20px;
|
||||
border-radius: 12px;
|
||||
spacing: 20px;
|
||||
background-color: @bg-alt;
|
||||
cursor: pointer;
|
||||
width: 200px; /* Width of each element */
|
||||
height: 50px; /* Height of each element */
|
||||
}
|
||||
|
||||
element-icon {
|
||||
size: 33%;
|
||||
horizontal-align: 0.5;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
element-text {
|
||||
horizontal-align: 0.5;
|
||||
background-color: transparent;
|
||||
text-color: inherit;
|
||||
}
|
||||
|
||||
/* Default state of elements */
|
||||
element normal.normal {
|
||||
background-color: @bg-alt;
|
||||
text-color: @fg-col;
|
||||
}
|
||||
|
||||
/* Selected entry in the list */
|
||||
element selected.normal {
|
||||
background-color: @blue;
|
||||
text-color: @bg-col; /* Invert text color for contrast */
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
# values in {NAME} syntax are provided by python using .replace()
|
||||
#
|
||||
[Unit]
|
||||
Description=FastAnime Background Worker
|
||||
Description=Viu Background Worker
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
# Ensure you have the full path to your fastanime executable
|
||||
# Use `which fastanime` to find it
|
||||
# Ensure you have the full path to your viu executable
|
||||
# Use `which viu` to find it
|
||||
ExecStart={EXECUTABLE} worker --log
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
BIN
viu_media/assets/icons/logo.ico
Normal file
BIN
viu_media/assets/icons/logo.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
BIN
viu_media/assets/icons/logo.png
Normal file
BIN
viu_media/assets/icons/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 276 KiB |
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# FastAnime Airing Schedule Info Script Template
|
||||
# Viu Airing Schedule Info Script Template
|
||||
# This script formats and displays airing schedule details in the FZF preview pane.
|
||||
# Python injects the actual data values into the placeholders.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# FastAnime Character Info Script Template
|
||||
# Viu Character Info Script Template
|
||||
# This script formats and displays character details in the FZF preview pane.
|
||||
# Python injects the actual data values into the placeholders.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user