Skip to content

Commit

Permalink
add custom syncplay configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixthrush committed Nov 12, 2024
1 parent bf64dc1 commit 51544d5
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 26 deletions.
42 changes: 23 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,14 @@ aniworld --help
```

```
usage: aniworld [-h] [-v] [-d] [-u] [-U {mpv,yt-dlp,syncplay,all}] [-s SLUG] [-l LINK]
[-q QUERY] [-e EPISODE [EPISODE ...]] [-f EPISODE_FILE] [-lf]
[-a {Watch,Download,Syncplay}] [-o OUTPUT] [-O OUTPUT_DIRECTORY]
usage: aniworld [-h] [-v] [-d] [-u] [-U {mpv,yt-dlp,syncplay,all}] [-s SLUG]
[-l LINK] [-q QUERY] [-e EPISODE [EPISODE ...]]
[-f EPISODE_FILE] [-lf] [-a {Watch,Download,Syncplay}]
[-o OUTPUT] [-O OUTPUT_DIRECTORY]
[-L {German Dub,English Sub,German Sub}]
[-p {Vidoza,Streamtape,VOE,Doodstream}] [-A {High,Low,Remove}]
[-sH SYNCPLAY_HOSTNAME] [-sU SYNCPLAY_USERNAME] [-sR SYNCPLAY_ROOM]
[-sH SYNCPLAY_HOSTNAME] [-sU SYNCPLAY_USERNAME]
[-sR SYNCPLAY_ROOM]
[-sP SYNCPLAY_PASSWORD [SYNCPLAY_PASSWORD ...]] [-k] [-K]
[-r [RANDOM_ANIME]] [-D] [-C] [-x PROXY] [-w]
Expand All @@ -301,8 +303,9 @@ General Options:
Search Options:
-s SLUG, --slug SLUG Search query - E.g. demon-slayer-kimetsu-no-yaiba
-l LINK, --link LINK Search query - E.g. https://aniworld.to/anime/stream/demon-
slayer-kimetsu-no-yaiba
-l LINK, --link LINK Search query - E.g.
https://aniworld.to/anime/stream/demon-slayer-kimetsu-
no-yaiba
-q QUERY, --query QUERY
Search query input - E.g. demon
Expand All @@ -311,49 +314,51 @@ Episode Options:
List of episode URLs
-f EPISODE_FILE, --episode-file EPISODE_FILE
File path containing a list of episode URLs
-lf, --episode-local NOT IMPLEMENTED YET - Use local episode files instead of URLs
-lf, --episode-local NOT IMPLEMENTED YET - Use local episode files instead
of URLs
Action Options:
-a {Watch,Download,Syncplay}, --action {Watch,Download,Syncplay}
Action to perform
-o OUTPUT, --output OUTPUT
Download directory E.g. /Users/phoenixthrush/Downloads
-O OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY
Final download directory E.g ExampleDirectory, defaults to anime
name if not specified
Final download directory E.g ExampleDirectory,
defaults to anime name if not specified
-L {German Dub,English Sub,German Sub}, --language {German Dub,English Sub,German Sub}
Language choice
-p {Vidoza,Streamtape,VOE,Doodstream}, --provider {Vidoza,Streamtape,VOE,Doodstream}
Provider choice
Anime4K Options:
-A {High,Low,Remove}, --anime4k {High,Low,Remove}
Set Anime4K optimised mode (High Eg.: GTX 1080, RTX 2070, RTX
3060, RX 590, Vega 56, 5700XT, 6600XT; Low Eg.: GTX 980, GTX
1060, RX 570, or Remove).
Set Anime4K optimised mode (High Eg.: GTX 1080, RTX
2070, RTX 3060, RX 590, Vega 56, 5700XT, 6600XT; Low
Eg.: GTX 980, GTX 1060, RX 570, or Remove).
Syncplay Options:
-sH SYNCPLAY_HOSTNAME, --syncplay-hostname SYNCPLAY_HOSTNAME
NOT IMPLEMENTED YET - Set syncplay hostname
Set syncplay hostname
-sU SYNCPLAY_USERNAME, --syncplay-username SYNCPLAY_USERNAME
NOT IMPLEMENTED YET - Set syncplay username
Set syncplay username
-sR SYNCPLAY_ROOM, --syncplay-room SYNCPLAY_ROOM
NOT IMPLEMENTED YET - Set syncplay room
Set syncplay room
-sP SYNCPLAY_PASSWORD [SYNCPLAY_PASSWORD ...], --syncplay-password SYNCPLAY_PASSWORD [SYNCPLAY_PASSWORD ...]
Set a syncplay room password
Miscellaneous Options:
-k, --aniskip Skip intro and outro
-K, --keep-watching Continue watching
-r [RANDOM_ANIME], --random-anime [RANDOM_ANIME]
Select random anime (default genre is "all", Eg.: Drama)
Select random anime (default genre is "all", Eg.:
Drama)
-D, --only-direct-link
Output direct link
-C, --only-command Output command
-x PROXY, --proxy PROXY
Set HTTP Proxy - E.g. http://0.0.0.0:8080
-w, --use-playwright Bypass fetching with a headless browser using Playwright instead
(EXPERIMENTAL!!!)
-w, --use-playwright Bypass fetching with a headless browser using
Playwright instead (EXPERIMENTAL!!!)
```
<p align="right">(<a href="#readme-top">back to top</a>)</p>
Expand Down Expand Up @@ -424,7 +429,6 @@ These packages are automatically installed when you set up AniWorld Downloader u
- [x] Fix --only-direct-link and only-command
### Upcoming Tasks
- [ ] Implement missing argument options
- [ ] Syncplay support for other sites and local playback
- [ ] Implement an ordered list for provider fallback in globals.py
- [ ] Add support for other sites (anime-base.net)
Expand Down
20 changes: 16 additions & 4 deletions src/aniworld/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def create(self):
self.expandable_text = self.add(
npyscreen.MultiLineEdit,
value=text_content,
max_height=30,
max_height=None,
editable=False
)

Expand Down Expand Up @@ -429,9 +429,9 @@ def parse_arguments():

# Syncplay options
syncplay_group = parser.add_argument_group('Syncplay Options')
syncplay_group.add_argument('-sH', '--syncplay-hostname', type=str, help='NOT IMPLEMENTED YET - Set syncplay hostname')
syncplay_group.add_argument('-sU', '--syncplay-username', type=str, help='NOT IMPLEMENTED YET - Set syncplay username')
syncplay_group.add_argument('-sR', '--syncplay-room', type=str, help='NOT IMPLEMENTED YET - Set syncplay room')
syncplay_group.add_argument('-sH', '--syncplay-hostname', type=str, help='Set syncplay hostname')
syncplay_group.add_argument('-sU', '--syncplay-username', type=str, help='Set syncplay username')
syncplay_group.add_argument('-sR', '--syncplay-room', type=str, help='Set syncplay room')
syncplay_group.add_argument('-sP', '--syncplay-password', type=str, nargs='+', help='Set a syncplay room password')

# Miscellaneous options
Expand Down Expand Up @@ -529,6 +529,18 @@ def parse_arguments():
os.environ['SYNCPLAY_PASSWORD'] = args.syncplay_password[0]
logging.debug("Syncplay password set.")

if args.syncplay_hostname:
os.environ['SYNCPLAY_HOSTNAME'] = args.syncplay_hostname
logging.debug("Syncplay hostname set.")

if args.syncplay_username:
os.environ['SYNCPLAY_USERNAME'] = args.syncplay_username
logging.debug("Syncplay username set.")

if args.syncplay_room:
os.environ['SYNCPLAY_ROOM'] = args.syncplay_room
logging.debug("Syncplay room set.")

if args.output_directory:
os.environ['OUTPUT_DIRECTORY'] = args.output_directory
logging.debug("Output directory set.")
Expand Down
26 changes: 23 additions & 3 deletions src/aniworld/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,40 @@ def build_syncplay_command(
link, mpv_title, aniskip_options
)
syncplay = "SyncplayConsole" if platform.system() == "Windows" else "syncplay"
syncplay_password = os.getenv("SYNCPLAY_PASSWORD")
anime_title = mpv_title.split(" - ")[0].replace(" ", "_")

syncplay_password = os.getenv("SYNCPLAY_PASSWORD")
syncplay_hostname = os.getenv("SYNCPLAY_HOSTNAME")
syncplay_username = os.getenv("SYNCPLAY_USERNAME")
syncplay_room = os.getenv("SYNCPLAY_ROOM")

logging.debug("Syncplay password: %s, Syncplay hostname: %s, Syncplay username: %s, Syncplay room: %s",
syncplay_password,
syncplay_hostname,
syncplay_username,
syncplay_room
)

if syncplay_password:
room_name = f"aniworld-{hashlib.sha256((syncplay_password + anime_title).encode()).hexdigest()}"
else:
room_name = f"aniworld-{hashlib.sha256(anime_title.encode()).hexdigest()}"

if not syncplay_hostname:
syncplay_hostname = "syncplay.pl:8997"

if not syncplay_username:
syncplay_username = getpass.getuser()

if syncplay_room:
room_name = syncplay_room

command = [
syncplay,
"--no-gui",
"--no-store",
"--host", "syncplay.pl:8997",
"--name", getpass.getuser(),
"--host", syncplay_hostname,
"--name", syncplay_username,
"--room", room_name,
"--player-path", shutil.which("mpv"),
]
Expand Down

0 comments on commit 51544d5

Please sign in to comment.