sdaqo / anipy-cli

Little tool in python to watch and download anime from the terminal (the better way to watch anime). Also applicable as an API
https://sdaqo.github.io/anipy-cli
GNU General Public License v3.0
270 stars 40 forks source link

Soft fail instead of Hard fail for pypresence not finding Discord running #71

Closed Prashanthvsdvn closed 2 years ago

Prashanthvsdvn commented 2 years ago

Not a bug per se, more like feature request. Is it possible for Discord presence script to just show warning and continue with the script instead of hard failing, when Discord is not open. Sometimes I don't want to open discord and keep watching anime and I don't want to keep changing the config all the time. Or maybe even a flag option to skip discord presence even when enabled in config works.

Error log when trying to run without Discord open

Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python310\Scripts\anipy-cli.exe\__main__.py", line 4, in <module>
  File "C:\Python310\lib\site-packages\anipy_cli\run_anipy_cli.py", line 2, in <module>
    from anipy_cli import cli
  File "C:\Python310\lib\site-packages\anipy_cli\cli.py", line 38, in <module>
    rpc_client = dc_presence_connect()
  File "C:\Python310\lib\site-packages\anipy_cli\player.py", line 80, in dc_presence_connect
    rpc_client = Presence(CLIENT_ID)
  File "C:\Python310\lib\site-packages\pypresence\presence.py", line 13, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Python310\lib\site-packages\pypresence\baseclient.py", line 28, in __init__
    raise DiscordNotFound
pypresence.exceptions.DiscordNotFound: Could not find Discord installed and running on this machine.
sdaqo commented 2 years ago

Ah yeah I noticed that but kinda forgot about it. I will do this if I find some time today.

Prashanthvsdvn commented 2 years ago

Describe the bug Reopening this because the script fails now at a different point. The script warns about not initializing discord but continues to enter and interact. However, if you try to watch an episode, it fails citing unable to update rpc client

To Reproduce Steps to reproduce the behavior:

  1. Set Discord Presence variable to True
  2. Kill all instance of discord
  3. Open anipy-cli
  4. Search for anime and episode
  5. Episode plays but script on the terminal crashes

Expected behavior Program should not crash.

Info

Name: anipy-cli
Version: 2.4.24
Summary: Little tool in python to watch anime from the terminal (the better way to watch anime)
Home-page: https://github.com/sdaqo/anipy-cli
Author: sdaqo
Author-email: sdaqo.dev@protonmail.com
License: GPL-3.0
Location: c:\python310\lib\site-packages
Requires: better-ffmpeg-progress, bs4, kitsu.py-extended, m3u8, moviepy, pycryptodomex, pypresence, python-dateutil, requests, tqdm
Required-by:

Platform

Additional context Error log

Discord is not opened, can't initialize Discord Presence
Search: summertime render
[1] Summertime Render
Enter Number: 1
Episode [1-15]
>> 14
Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python310\Scripts\anipy-cli.exe\__main__.py", line 7, in <module>
  File "C:\Python310\lib\site-packages\anipy_cli\run_anipy_cli.py", line 8, in main
    cli.main()
  File "C:\Python310\lib\site-packages\anipy_cli\cli.py", line 668, in main
    default_cli(args.quality, player)
  File "C:\Python310\lib\site-packages\anipy_cli\cli.py", line 58, in default_cli
    sub_proc = start_player(show_entry, rpc_client, player)
  File "C:\Python310\lib\site-packages\anipy_cli\player.py", line 74, in start_player
    dc_presence(dc_media_title, entry.category_url, rpc_client)
  File "C:\Python310\lib\site-packages\anipy_cli\player.py", line 98, in dc_presence
    rpc_client.update(
AttributeError: 'NoneType' object has no attribute 'update'
Prashanthvsdvn commented 2 years ago

@sdaqo unable to change state to open. should I open as new issue??

sdaqo commented 2 years ago

No don't, I know what causes the fail, will patch it.