eiga-player 0.1.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. eiga_player-0.1.9/MANIFEST.in +4 -0
  2. eiga_player-0.1.9/PKG-INFO +218 -0
  3. eiga_player-0.1.9/README.md +207 -0
  4. eiga_player-0.1.9/pyproject.toml +36 -0
  5. eiga_player-0.1.9/setup.cfg +4 -0
  6. eiga_player-0.1.9/src/eiga_player/__init__.py +14 -0
  7. eiga_player-0.1.9/src/eiga_player/__main__.py +7 -0
  8. eiga_player-0.1.9/src/eiga_player/assets/hls.min.js +2 -0
  9. eiga_player-0.1.9/src/eiga_player/backends.py +207 -0
  10. eiga_player-0.1.9/src/eiga_player/browser.py +266 -0
  11. eiga_player-0.1.9/src/eiga_player/cli.py +107 -0
  12. eiga_player-0.1.9/src/eiga_player/main.py +20 -0
  13. eiga_player-0.1.9/src/eiga_player/models.py +165 -0
  14. eiga_player-0.1.9/src/eiga_player/preflight.py +45 -0
  15. eiga_player-0.1.9/src/eiga_player/router.py +59 -0
  16. eiga_player-0.1.9/src/eiga_player/webview_player.py +123 -0
  17. eiga_player-0.1.9/src/eiga_player.egg-info/PKG-INFO +218 -0
  18. eiga_player-0.1.9/src/eiga_player.egg-info/SOURCES.txt +28 -0
  19. eiga_player-0.1.9/src/eiga_player.egg-info/dependency_links.txt +1 -0
  20. eiga_player-0.1.9/src/eiga_player.egg-info/entry_points.txt +2 -0
  21. eiga_player-0.1.9/src/eiga_player.egg-info/requires.txt +6 -0
  22. eiga_player-0.1.9/src/eiga_player.egg-info/top_level.txt +1 -0
  23. eiga_player-0.1.9/tests/test_backends.py +86 -0
  24. eiga_player-0.1.9/tests/test_browser.py +137 -0
  25. eiga_player-0.1.9/tests/test_cli.py +50 -0
  26. eiga_player-0.1.9/tests/test_models.py +70 -0
  27. eiga_player-0.1.9/tests/test_package.py +32 -0
  28. eiga_player-0.1.9/tests/test_preflight.py +45 -0
  29. eiga_player-0.1.9/tests/test_router.py +121 -0
  30. eiga_player-0.1.9/tests/test_webview_player.py +132 -0
@@ -0,0 +1,4 @@
1
+ include pyproject.toml
2
+ include README.md
3
+ recursive-include src/eiga_player/assets *.js
4
+ recursive-include tests *.py
@@ -0,0 +1,218 @@
1
+ Metadata-Version: 2.4
2
+ Name: eiga-player
3
+ Version: 0.1.9
4
+ Summary: Standalone URL player: VLC, mpv and a dedicated player-window fallback
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: httpx>=0.28.1
8
+ Requires-Dist: PyGObject>=3.50; sys_platform == "linux"
9
+ Requires-Dist: pywebview>=6.2.1
10
+ Requires-Dist: yt-dlp>=2025.1.1
11
+
12
+ # eiga-player
13
+
14
+ eiga-player is a **standalone tool built to handle different links and URLs in one
15
+ place**. It removes the need for separate tools like VLC, mpv and a browser: give it
16
+ a URL (or a JSON request) and it picks the right way to play it. It works on both
17
+ **Windows and Linux**.
18
+
19
+ You supply the URL — the tool does not scrape sites, search catalogues, or choose
20
+ releases. It handles direct media files, HLS playlists, YouTube links, embed/watch
21
+ pages and magnet links, including the headers, referer and cookies those URLs often
22
+ need.
23
+
24
+ ## What it handles
25
+
26
+ 1. **YouTube links** → mpv directly, with yt-dlp support built in.
27
+ 2. **Direct media / HLS URLs** → VLC first, then mpv if VLC is missing or fails.
28
+ 3. **Embed / watch pages** → opened directly in a dedicated player window. They are
29
+ detected automatically from `/embed/`, `/watch`, `#watch`, `.html`, etc.; use
30
+ `--kind stream` if a site's URL needs help.
31
+ 4. **Magnet links** → handed to your operating system's torrent handler.
32
+ 5. If VLC and mpv both fail → a **dedicated player window**:
33
+ - a normal OS window (title bar, no URL bar, tabs, or browser toolbar) backed by
34
+ the system webview — WebView2 on Windows, WebKitGTK on Linux;
35
+ - direct media/HLS is served through a small loopback proxy with a minimal
36
+ `<video>` page (bundled `hls.js`), so referer/headers/cookies still reach the
37
+ source.
38
+ 6. **Fallback:** if that window cannot start, the URL is opened in your system
39
+ browser. On Linux, missing PyGObject/WebKitGTK is detected before pywebview
40
+ is asked to create a window, so no GTK/Qt import tracebacks are printed. If no
41
+ browser opens either, the URL is printed for manual copying.
42
+
43
+ No browser or player engine is bundled — the tool uses what your system already has.
44
+
45
+ ## Quick start
46
+
47
+ ```bash
48
+ # Direct media URL
49
+ eiga-player "https://example.com/movie.mp4" \
50
+ --title "Leo" \
51
+ --referer "https://example.com/" \
52
+ --header "User-Agent: Mozilla/5.0"
53
+
54
+ # Embed page — quote URLs containing '&'
55
+ eiga-player "https://embed.vidsrc.si/embed/tv/95479/1/1?autoplay=1&ds_lang=en"
56
+
57
+ # YouTube
58
+ eiga-player "https://www.youtube.com/watch?v=xxxx"
59
+
60
+ # Magnet
61
+ eiga-player "magnet:?xt=urn:btih:..."
62
+ ```
63
+
64
+ Unquoted `&` makes the shell treat the rest as a background command, so the player
65
+ receives a truncated URL. Always quote URLs with query parameters.
66
+
67
+ From source, in the project directory:
68
+
69
+ ```bash
70
+ uv run python -m eiga_player "URL"
71
+ # or, after `uv sync`, the installed command
72
+ uv run eiga-player "URL"
73
+ ```
74
+
75
+ ## Use as a Python library
76
+
77
+ The same package is importable without argparse and without terminating your process:
78
+
79
+ ```python
80
+ from eiga_player import PlayRequest, play
81
+
82
+ request = PlayRequest(
83
+ "https://example.com/movie.mp4",
84
+ title="Leo",
85
+ referer="https://example.com/",
86
+ headers={"User-Agent": "Mozilla/5.0"},
87
+ )
88
+ played = play(request) # True on success, False if every backend failed
89
+ ```
90
+
91
+ `route` is also exported as an alias of `play`. Argument parsing, exit codes and
92
+ the bundled yt-dlp shim stay in the CLI layer; the library entry point only returns
93
+ a bool.
94
+
95
+ ## JSON input
96
+
97
+ For scripts or other programs, pass a JSON file or stdin:
98
+
99
+ ```bash
100
+ eiga-player --json - <<'EOF'
101
+ {
102
+ "url": "https://example.com/embed/123",
103
+ "title": "Episode 1",
104
+ "referer": "https://example.com/",
105
+ "headers": {"User-Agent": "Mozilla/5.0"},
106
+ "cookies": "session=abc",
107
+ "kind": "stream",
108
+ "timeout": 0
109
+ }
110
+ EOF
111
+ ```
112
+
113
+ ```bash
114
+ eiga-player --json request.json
115
+ ```
116
+
117
+ CLI flags override JSON fields.
118
+
119
+ | Field | Meaning |
120
+ | --- | --- |
121
+ | `url` | URL to play (required; HTTP(S) or `magnet:`) |
122
+ | `title` | Window title |
123
+ | `referer` | Source page URL; many hosts require this to allow playback |
124
+ | `headers` | Object of HTTP header strings |
125
+ | `cookies` | Cookie header |
126
+ | `kind` | `media` (media file/playlist), `stream` (embed/watch page), or `magnet` |
127
+ | `timeout` | Seconds before the player window auto-closes; `0` = until you close it |
128
+ | `verbose` | Show local proxy request logs |
129
+
130
+ Exit codes: `0` played, `1` every option failed, `2` bad input, `130` interrupted.
131
+
132
+ `--timeout` is handy for automation and testing; normal interactive use should leave
133
+ it at `0` and close the window yourself.
134
+
135
+ ## Flags
136
+
137
+ ```
138
+ usage: eiga-player [-h] [--json PATH] [--title TITLE] [--referer REFERER]
139
+ [--header NAME: VALUE] [--cookies COOKIES]
140
+ [--kind {media,stream,magnet}] [--timeout SECONDS]
141
+ [--verbose] [--version]
142
+ [url]
143
+ ```
144
+
145
+ `--header` can be repeated. Run `eiga-player --help` for the full list.
146
+
147
+ ## System requirements and overrides
148
+
149
+ VLC and mpv are found on `PATH` and in common install locations. You can force specific
150
+ binaries with environment variables:
151
+
152
+ ```bash
153
+ EIGA_VLC=/path/to/vlc # force a VLC executable
154
+ EIGA_MPV=/path/to/mpv # force an mpv executable
155
+ EIGA_NO_WEBVIEW=1 # skip the player window, test the emergency browser path
156
+ ```
157
+
158
+ The player window needs WebView2 on Windows (present on most Windows 10/11 installs)
159
+ or WebKitGTK on Linux (`libwebkit2gtk-4.1`, `gir1.2-webkit2-4.1`). VLC cannot receive a
160
+ `Cookie` header from the command line; mpv and the window proxy can.
161
+
162
+ ## Install and build
163
+
164
+ Python 3.10+ is required to build from source.
165
+
166
+ ```bash
167
+ uv sync
168
+ uv run python -m unittest discover -s tests -v
169
+ uv run python -m eiga_player --help
170
+ ```
171
+
172
+ Build a single-file binary:
173
+
174
+ ```bash
175
+ ./build.sh # Linux/Termux → dist/eiga-player
176
+ ./build.sh --install # also copy to ~/.local/bin
177
+ ```
178
+
179
+ On Windows:
180
+
181
+ ```powershell
182
+ .\build.ps1 # dist\eiga-player.exe
183
+ .\build.ps1 -Install # also copy to %LOCALAPPDATA%\Programs\eiga-player
184
+ ```
185
+
186
+ CI builds Linux x86_64 and Windows x86_64 binaries from the same spec. The binary
187
+ includes Python, yt-dlp, httpx, pywebview and hls.js; it does **not** bundle VLC,
188
+ mpv, WebView2/WebKitGTK or a browser. The same source also builds a wheel and sdist
189
+ with `python -m build`; installing the package provides both `import eiga_player`
190
+ and the `eiga-player` command.
191
+
192
+ ## Releases and version bumps
193
+
194
+ **Every push to `main` publishes a release automatically.** CI reads the latest GitHub
195
+ release tag and bumps the patch number (`v0.1.0` → `v0.1.1`), injects it into the
196
+ binary, and uploads versioned assets. No manual tag or file edit is needed.
197
+
198
+ To force an exact version instead, push a semantic tag:
199
+
200
+ ```bash
201
+ git tag v0.2.0
202
+ git push origin v0.2.0
203
+ ```
204
+
205
+ A release then contains `eiga-player-0.2.0-linux-x86_64` and
206
+ `eiga-player-0.2.0-windows-x86_64.exe`, and the binary reports `eiga-player 0.2.0`.
207
+
208
+ ## Security notes
209
+
210
+ The loopback proxy binds only to `127.0.0.1` on an ephemeral port. Every proxied URL is
211
+ HMAC-signed with a per-run secret, so another local program cannot use the page to make
212
+ the player fetch arbitrary URLs. Header values are checked for CR/LF injection. The
213
+ bundled `hls.js` is a JavaScript file, not a browser.
214
+
215
+ ## Disclaimer
216
+
217
+ This project does not host media. Use it only with content you are allowed to access,
218
+ and follow the terms of the source sites.
@@ -0,0 +1,207 @@
1
+ # eiga-player
2
+
3
+ eiga-player is a **standalone tool built to handle different links and URLs in one
4
+ place**. It removes the need for separate tools like VLC, mpv and a browser: give it
5
+ a URL (or a JSON request) and it picks the right way to play it. It works on both
6
+ **Windows and Linux**.
7
+
8
+ You supply the URL — the tool does not scrape sites, search catalogues, or choose
9
+ releases. It handles direct media files, HLS playlists, YouTube links, embed/watch
10
+ pages and magnet links, including the headers, referer and cookies those URLs often
11
+ need.
12
+
13
+ ## What it handles
14
+
15
+ 1. **YouTube links** → mpv directly, with yt-dlp support built in.
16
+ 2. **Direct media / HLS URLs** → VLC first, then mpv if VLC is missing or fails.
17
+ 3. **Embed / watch pages** → opened directly in a dedicated player window. They are
18
+ detected automatically from `/embed/`, `/watch`, `#watch`, `.html`, etc.; use
19
+ `--kind stream` if a site's URL needs help.
20
+ 4. **Magnet links** → handed to your operating system's torrent handler.
21
+ 5. If VLC and mpv both fail → a **dedicated player window**:
22
+ - a normal OS window (title bar, no URL bar, tabs, or browser toolbar) backed by
23
+ the system webview — WebView2 on Windows, WebKitGTK on Linux;
24
+ - direct media/HLS is served through a small loopback proxy with a minimal
25
+ `<video>` page (bundled `hls.js`), so referer/headers/cookies still reach the
26
+ source.
27
+ 6. **Fallback:** if that window cannot start, the URL is opened in your system
28
+ browser. On Linux, missing PyGObject/WebKitGTK is detected before pywebview
29
+ is asked to create a window, so no GTK/Qt import tracebacks are printed. If no
30
+ browser opens either, the URL is printed for manual copying.
31
+
32
+ No browser or player engine is bundled — the tool uses what your system already has.
33
+
34
+ ## Quick start
35
+
36
+ ```bash
37
+ # Direct media URL
38
+ eiga-player "https://example.com/movie.mp4" \
39
+ --title "Leo" \
40
+ --referer "https://example.com/" \
41
+ --header "User-Agent: Mozilla/5.0"
42
+
43
+ # Embed page — quote URLs containing '&'
44
+ eiga-player "https://embed.vidsrc.si/embed/tv/95479/1/1?autoplay=1&ds_lang=en"
45
+
46
+ # YouTube
47
+ eiga-player "https://www.youtube.com/watch?v=xxxx"
48
+
49
+ # Magnet
50
+ eiga-player "magnet:?xt=urn:btih:..."
51
+ ```
52
+
53
+ Unquoted `&` makes the shell treat the rest as a background command, so the player
54
+ receives a truncated URL. Always quote URLs with query parameters.
55
+
56
+ From source, in the project directory:
57
+
58
+ ```bash
59
+ uv run python -m eiga_player "URL"
60
+ # or, after `uv sync`, the installed command
61
+ uv run eiga-player "URL"
62
+ ```
63
+
64
+ ## Use as a Python library
65
+
66
+ The same package is importable without argparse and without terminating your process:
67
+
68
+ ```python
69
+ from eiga_player import PlayRequest, play
70
+
71
+ request = PlayRequest(
72
+ "https://example.com/movie.mp4",
73
+ title="Leo",
74
+ referer="https://example.com/",
75
+ headers={"User-Agent": "Mozilla/5.0"},
76
+ )
77
+ played = play(request) # True on success, False if every backend failed
78
+ ```
79
+
80
+ `route` is also exported as an alias of `play`. Argument parsing, exit codes and
81
+ the bundled yt-dlp shim stay in the CLI layer; the library entry point only returns
82
+ a bool.
83
+
84
+ ## JSON input
85
+
86
+ For scripts or other programs, pass a JSON file or stdin:
87
+
88
+ ```bash
89
+ eiga-player --json - <<'EOF'
90
+ {
91
+ "url": "https://example.com/embed/123",
92
+ "title": "Episode 1",
93
+ "referer": "https://example.com/",
94
+ "headers": {"User-Agent": "Mozilla/5.0"},
95
+ "cookies": "session=abc",
96
+ "kind": "stream",
97
+ "timeout": 0
98
+ }
99
+ EOF
100
+ ```
101
+
102
+ ```bash
103
+ eiga-player --json request.json
104
+ ```
105
+
106
+ CLI flags override JSON fields.
107
+
108
+ | Field | Meaning |
109
+ | --- | --- |
110
+ | `url` | URL to play (required; HTTP(S) or `magnet:`) |
111
+ | `title` | Window title |
112
+ | `referer` | Source page URL; many hosts require this to allow playback |
113
+ | `headers` | Object of HTTP header strings |
114
+ | `cookies` | Cookie header |
115
+ | `kind` | `media` (media file/playlist), `stream` (embed/watch page), or `magnet` |
116
+ | `timeout` | Seconds before the player window auto-closes; `0` = until you close it |
117
+ | `verbose` | Show local proxy request logs |
118
+
119
+ Exit codes: `0` played, `1` every option failed, `2` bad input, `130` interrupted.
120
+
121
+ `--timeout` is handy for automation and testing; normal interactive use should leave
122
+ it at `0` and close the window yourself.
123
+
124
+ ## Flags
125
+
126
+ ```
127
+ usage: eiga-player [-h] [--json PATH] [--title TITLE] [--referer REFERER]
128
+ [--header NAME: VALUE] [--cookies COOKIES]
129
+ [--kind {media,stream,magnet}] [--timeout SECONDS]
130
+ [--verbose] [--version]
131
+ [url]
132
+ ```
133
+
134
+ `--header` can be repeated. Run `eiga-player --help` for the full list.
135
+
136
+ ## System requirements and overrides
137
+
138
+ VLC and mpv are found on `PATH` and in common install locations. You can force specific
139
+ binaries with environment variables:
140
+
141
+ ```bash
142
+ EIGA_VLC=/path/to/vlc # force a VLC executable
143
+ EIGA_MPV=/path/to/mpv # force an mpv executable
144
+ EIGA_NO_WEBVIEW=1 # skip the player window, test the emergency browser path
145
+ ```
146
+
147
+ The player window needs WebView2 on Windows (present on most Windows 10/11 installs)
148
+ or WebKitGTK on Linux (`libwebkit2gtk-4.1`, `gir1.2-webkit2-4.1`). VLC cannot receive a
149
+ `Cookie` header from the command line; mpv and the window proxy can.
150
+
151
+ ## Install and build
152
+
153
+ Python 3.10+ is required to build from source.
154
+
155
+ ```bash
156
+ uv sync
157
+ uv run python -m unittest discover -s tests -v
158
+ uv run python -m eiga_player --help
159
+ ```
160
+
161
+ Build a single-file binary:
162
+
163
+ ```bash
164
+ ./build.sh # Linux/Termux → dist/eiga-player
165
+ ./build.sh --install # also copy to ~/.local/bin
166
+ ```
167
+
168
+ On Windows:
169
+
170
+ ```powershell
171
+ .\build.ps1 # dist\eiga-player.exe
172
+ .\build.ps1 -Install # also copy to %LOCALAPPDATA%\Programs\eiga-player
173
+ ```
174
+
175
+ CI builds Linux x86_64 and Windows x86_64 binaries from the same spec. The binary
176
+ includes Python, yt-dlp, httpx, pywebview and hls.js; it does **not** bundle VLC,
177
+ mpv, WebView2/WebKitGTK or a browser. The same source also builds a wheel and sdist
178
+ with `python -m build`; installing the package provides both `import eiga_player`
179
+ and the `eiga-player` command.
180
+
181
+ ## Releases and version bumps
182
+
183
+ **Every push to `main` publishes a release automatically.** CI reads the latest GitHub
184
+ release tag and bumps the patch number (`v0.1.0` → `v0.1.1`), injects it into the
185
+ binary, and uploads versioned assets. No manual tag or file edit is needed.
186
+
187
+ To force an exact version instead, push a semantic tag:
188
+
189
+ ```bash
190
+ git tag v0.2.0
191
+ git push origin v0.2.0
192
+ ```
193
+
194
+ A release then contains `eiga-player-0.2.0-linux-x86_64` and
195
+ `eiga-player-0.2.0-windows-x86_64.exe`, and the binary reports `eiga-player 0.2.0`.
196
+
197
+ ## Security notes
198
+
199
+ The loopback proxy binds only to `127.0.0.1` on an ephemeral port. Every proxied URL is
200
+ HMAC-signed with a per-run secret, so another local program cannot use the page to make
201
+ the player fetch arbitrary URLs. Header values are checked for CR/LF injection. The
202
+ bundled `hls.js` is a JavaScript file, not a browser.
203
+
204
+ ## Disclaimer
205
+
206
+ This project does not host media. Use it only with content you are allowed to access,
207
+ and follow the terms of the source sites.
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=82"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "eiga-player"
7
+ version = "0.1.9"
8
+ description = "Standalone URL player: VLC, mpv and a dedicated player-window fallback"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ dependencies = [
12
+ "httpx>=0.28.1",
13
+ "PyGObject>=3.50; sys_platform == 'linux'",
14
+ "pywebview>=6.2.1",
15
+ "yt-dlp>=2025.1.1",
16
+ ]
17
+
18
+ [project.scripts]
19
+ eiga-player = "eiga_player.cli:main"
20
+
21
+ [tool.setuptools]
22
+ package-dir = { "" = "src" }
23
+ py-modules = []
24
+ include-package-data = true
25
+
26
+ [tool.setuptools.packages.find]
27
+ where = ["src"]
28
+ include = ["eiga_player*"]
29
+
30
+ [tool.setuptools.package-data]
31
+ eiga_player = ["assets/*.js", "assets/hls.min.js"]
32
+
33
+ [dependency-groups]
34
+ dev = [
35
+ "pyinstaller>=6.21.0",
36
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,14 @@
1
+ """Dual-purpose URL player: importable library and standalone CLI/binary.
2
+
3
+ The CLI-specific parsing, exit codes and yt-dlp shim live in :mod:`eiga_player.cli`
4
+ and :mod:`eiga_player.main`. Importing this package only exposes the library API;
5
+ ``play``/``route`` return a bool and never call ``sys.exit()``.
6
+ """
7
+
8
+ from .models import PlayRequest
9
+ from .router import route
10
+ from .router import route as play
11
+
12
+ __version__ = "0.1.9"
13
+
14
+ __all__ = ["PlayRequest", "play", "route", "__version__"]
@@ -0,0 +1,7 @@
1
+ """Allow ``python -m eiga_player`` as well as the installed console script."""
2
+
3
+ from .main import run
4
+
5
+
6
+ if __name__ == "__main__":
7
+ run()