[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] FreeBSD Support #359

Closed
nxjosephofficial opened this issue Sep 22, 2024 · 14 comments
Closed

[BUG] FreeBSD Support #359

nxjosephofficial opened this issue Sep 22, 2024 · 14 comments
Labels
bug Something isn't working

Comments

@nxjosephofficial
Copy link
nxjosephofficial commented Sep 22, 2024

Hi. I do want to make this software and some plugins available in FreeBSD ports tree and I started to port this software within some plugins. Unfortunately, mov-cli isn't able to use already installed mpv on my system. I don't understand python either. Thanks.

Describe the bug:

I ran mov-cli -s youtube not like us and got those errors after i selected one video.

Mov-cli version: 4.4.12

Expected behaviour:
I would like to see mpv running the video that i've wanted because i spend time creating these ports on FreeBSD.

% pkg info -a | grep -E 'mov|pytube|devgoldy'
py311-devgoldyutils-3.0.0      Goldy's small python utils library
py311-mov-cli-4.4.12           Watch everything from your terminal
py311-mov-cli-test-1.1.7       mov-cli v4 plugin that let's you test mov-cli's capabilities
py311-mov-cli-youtube-1.3.4    mov-cli v4 plugin for watching youtube
py311-pytubefix-6.16.3         Library for downloading YouTube Videos

Steps to reproduce:

  1. Set youtube plugin in config
[mov-cli.plugins] # E.g: namespace = "package-name"
test = "mov-cli-test"
youtube = "mov-cli-youtube"
  1. run mov-cli -s youtube not like us

Screenshots:
bug

Logs:

without debug parameter:

�[38;5;51m[INFO]�[0m (�[1;37;40mmov_cli�[0m) - Using '�[36myoutube.DEFAULT�[0m' scraper...
�[38;5;51m[INFO]�[0m (�[1;37;40mmov_cli�[0m) - Searching for '�[38;5;214mnot like us�[0m'...
�[38;5;51m[INFO]�[0m (�[1;37;40mmov_cli�[0m) - Scraping '�[38;5;51mKendrick Lamar - Not Like Us ~ Kendrick Lamar�[0m'...
�[33;20m[WARNING]�[0m (�[1;37;40mmov_cli�[0m) - �[92m[YTDlpScraper�[92m]�[0m Couldn't find the right audio for your currently selected language so audio localisation will be disabled and the first audio from the YouTube video will be selected.
�[38;5;51m[INFO]�[0m (�[1;37;40mmov_cli�[0m) - Playing '�[36mKendrick Lamar - Not Like Us ~ Kendrick Lamar�[0m' with �[38;5;200mMPV�[0m...

Good Night, �[38;5;214myusuf�[0m.
    It's �[36m10:14 PM �[0mon a �[38;5;200mmagnificent �[38;5;139mSunday! �[0m

Traceback (most recent call last):
  File "/usr/local/bin/mov-cli", line 8, in <module>
    sys.exit(app())
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/mov_cli/cli/__main__.py", line 162, in app
    uwu_app()
  File "/usr/local/lib/python3.11/site-packages/typer/main.py", line 338, in __call__
    raise e
  File "/usr/local/lib/python3.11/site-packages/typer/main.py", line 321, in __call__
    return get_command(self)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/typer/core.py", line 665, in main
    return _main(
           ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/typer/core.py", line 197, in _main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/typer/main.py", line 703, in wrapper
    return callback(**use_params)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mov_cli/cli/__main__.py", line 158, in mov_cli
    play(media, metadata, chosen_scraper, chosen_episode, config)
  File "/usr/local/lib/python3.11/site-packages/mov_cli/cli/play.py", line 58, in play
    mov_cli_logger.debug(f"Called player with these args -> '{hide_ip(' '.join(popen.args), config.hide_ip)}'")
                                                                               ^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'args'

debug parameter output:

�[38;5;139m[DEBUG]�[0m (�[1;37;40mmov_cli�[0m) - Config -> {'version': 1, 'debug': True, 'player': 'mpv', 'quality': 'auto', 'skip_update_checker': False, 'auto_try_next_scraper': True, 'hide_ip': True, 'ui': {'preview': True, 'watch_options': True, 'display_quality': False}, 'plugins': {'test': 'mov-cli-test', 'youtube': 'mov-cli-youtube'}, 'scrapers': {'test': 'test.DEFAULT', 'default': 'youtube'}, 'http': {'timeout': 15}}
�[38;5;139m[DEBUG]�[0m (�[1;37;40mmov_cli�[0m) - Scraper args picked up on --> []
�[38;5;51m[INFO]�[0m (�[1;37;40mmov_cli�[0m) - Using '�[36myoutube.DEFAULT�[0m' scraper...
�[38;5;51m[INFO]�[0m (�[1;37;40mmov_cli�[0m) - Searching for '�[38;5;214mnot like us�[0m'...
[youtube:search] Extracting URL: ytsearch70:not like us

Good Night, �[38;5;214myusuf�[0m.
    It's �[36m10:37 PM �[0mon a �[38;5;200mbeautiful �[38;5;139mSunday! �[0m

[download] Downloading playlist: not like us
[youtube:search] query "not like us": Downloading web client config
[youtube:search] query "not like us" page 1: Downloading API JSON
[youtube:search] query "not like us" page 2: Downloading API JSON
[youtube:search] query "not like us" page 3: Downloading API JSON
[youtube:search] query "not like us" page 4: Downloading API JSON
[youtube:search] Playlist not like us: Downloading 70 items of 70
[download] Downloading item 1 of 70
[download] Downloading item 2 of 70
[download] Downloading item 3 of 70
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Downloading item 5 of 70
[download] Downloading item 6 of 70
[download] Downloading item 7 of 70
[download] Downloading item 8 of 70
[download] Downloading item 9 of 70
[download] Downloading item 10 of 70
[download] Downloading item 11 of 70
[download] Downloading item 12 of 70
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Downloading item 14 of 70
[download] Downloading item 15 of 70
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Downloading item 18 of 70
[download] Downloading item 19 of 70
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Downloading item 23 of 70
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Downloading item 25 of 70
[download] Downloading item 26 of 70
[download] Downloading item 27 of 70
[download] Downloading item 28 of 70
[download] Downloading item 29 of 70
[download] Downloading item 30 of 70
[download] Downloading item 31 of 70
[download] Downloading item 32 of 70
[download] Downloading item 33 of 70
[download] Downloading item 34 of 70
[download] Downloading item 35 of 70
[download] Downloading item 36 of 70
[download] Downloading item 37 of 70
[download] Downloading item 38 of 70
[download] Downloading item 39 of 70
[download] Downloading item 40 of 70
[download] Downloading item 41 of 70
[download] Downloading item 42 of 70
[download] Downloading item 43 of 70
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Downloading item 50 of 70
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Downloading item 54 of 70
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Downloading item 56 of 70
[download] Downloading item 57 of 70
[download] Downloading item 58 of 70
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Downloading item 60 of 70
[download] Downloading item 61 of 70
[download] Video is a YouTube short. Pass '--shorts' to the scraper to scrape for them.
[download] Downloading item 63 of 70
[download] Downloading item 64 of 70
[download] Downloading item 65 of 70
[download] Downloading item 66 of 70
[download] Downloading item 67 of 70
[download] Downloading item 68 of 70
[download] Downloading item 69 of 70
[download] Downloading item 70 of 70
[download] Finished downloading playlist: not like us
�[38;5;139m[DEBUG]�[0m (�[1;37;40mmov_cli�[0m) - �[92m[�[36mCache�[0m�[92m]�[0m Clearing all cache in file or section...
�[38;5;51m[INFO]�[0m (�[1;37;40mmov_cli�[0m) - Scraping '�[38;5;51mKendrick Lamar - Not Like Us ~ Kendrick Lamar�[0m'...
[youtube] Extracting URL: https://www.youtube.com/watch?v=H58vbez_m4E
[youtube] H58vbez_m4E: Downloading webpage
[youtube] H58vbez_m4E: Downloading ios player API JSON
[youtube] H58vbez_m4E: Downloading web creator player API JSON
[youtube] H58vbez_m4E: Downloading m3u8 information
�[33;20m[WARNING]�[0m (�[1;37;40mmov_cli�[0m) - �[92m[YTDlpScraper�[92m]�[0m Couldn't find the right audio for your currently selected language so audio localisation will be disabled and the first audio from the YouTube video will be selected.
�[38;5;139m[DEBUG]�[0m (�[1;37;40mmov_cli�[0m) - �[92m[�[36mCache�[0m�[92m]�[0m Setting 'https://www.youtube.com/watch?v=H58vbez_m4E' cache...
�[38;5;51m[INFO]�[0m (�[1;37;40mmov_cli�[0m) - Playing '�[36mKendrick Lamar - Not Like Us ~ Kendrick Lamar�[0m' with �[38;5;200mMPV�[0m...
Traceback (most recent call last):
  File "/usr/local/bin/mov-cli", line 8, in <module>
    sys.exit(app())
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/mov_cli/cli/__main__.py", line 162, in app
    uwu_app()
  File "/usr/local/lib/python3.11/site-packages/typer/main.py", line 338, in __call__
    raise e
  File "/usr/local/lib/python3.11/site-packages/typer/main.py", line 321, in __call__
    return get_command(self)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/typer/core.py", line 665, in main
    return _main(
           ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/typer/core.py", line 197, in _main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/typer/main.py", line 703, in wrapper
    return callback(**use_params)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/mov_cli/cli/__main__.py", line 158, in mov_cli
    play(media, metadata, chosen_scraper, chosen_episode, config)
  File "/usr/local/lib/python3.11/site-packages/mov_cli/cli/play.py", line 58, in play
    mov_cli_logger.debug(f"Called player with these args -> '{hide_ip(' '.join(popen.args), config.hide_ip)}'")
                                                                               ^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'args'

Platform:

  • OS: FreeBSD
  • Version: 14.1-P5

Checklist

  • [ X ] I have added logs.
  • [ X ] I have added my platform.
  • [ X ] I have added my version number.
  • [ X ] I am sure that this issue is not related to a plugin.

Additional info

FreeBSD platform was not available in the code and I added FreeBSD platform myself, maybe this problem caused by my patches. Here are patches applied to mov-cli.

==> ../../../../files/patch-mov__cli_utils_paths.py <==
--- mov_cli/utils/paths.py.orig	2024-09-22 18:37:43 UTC
+++ mov_cli/utils/paths.py
@@ -25,7 +25,7 @@ def get_appdata_directory(platform: SUPPORTED_PLATFORM
         user_profile = Path.home()
         appdata_dir = user_profile.joinpath("Library", "Application Support")
 
-    elif platform == "Linux" or platform == "Android" or platform == "iOS":
+    elif platform == "Linux" or platform == "FreeBSD" or platform == "Android" or platform == "iOS":
         user_profile = Path(os.getenv("HOME"))
         appdata_dir = user_profile.joinpath(".config")
 
@@ -49,7 +49,7 @@ def get_temp_directory(platform: SUPPORTED_PLATFORMS) 
     elif platform == "Darwin": # NOTE: Path maybe incorrect
         temp_directory = Path(os.getenv("TMPDIR"))
 
-    elif platform == "Linux" or platform == "iOS":
+    elif platform == "Linux" or platform == "FreeBSD" or platform == "iOS":
         linux_temp_dir = os.getenv("TMPDIR") # Respect the TMPDIR environment variable on Linux: https://unix.stackexchange.com/a/362107
 
         if linux_temp_dir is None:
@@ -78,7 +78,7 @@ def get_cache_directory(platform: SUPPORTED_PLATFORMS)
         user_profile = Path.home()
         cache_directory = user_profile.joinpath("Library", "Caches")
 
-    elif platform == "Linux" or platform == "Android" or platform == "iOS":
+    elif platform == "Linux" or platform == "FreeBSD" or platform == "Android" or platform == "iOS":
         user_profile = Path(os.getenv("HOME"))
         cache_directory = user_profile.joinpath(".cache")
 
@@ -87,4 +87,4 @@ def get_cache_directory(platform: SUPPORTED_PLATFORMS)
     cache_directory = cache_directory.joinpath("mov-cli")
     cache_directory.mkdir(exist_ok = True)
 
-    return cache_directory
\ No newline at end of file
+    return cache_directory

==> ../../../../files/patch-mov__cli_utils_platform.py <==
--- mov_cli/utils/platform.py.orig	2024-09-22 18:38:20 UTC
+++ mov_cli/utils/platform.py
@@ -4,7 +4,7 @@ if TYPE_CHECKING:
 if TYPE_CHECKING:
     from typing import Literal
 
-    SUPPORTED_PLATFORMS = Literal["Windows", "Linux", "Android", "Darwin", "iOS"]
+    SUPPORTED_PLATFORMS = Literal["Windows", "Linux", "FreeBSD", "Android", "Darwin", "iOS"]
 
 import sys
 import platform
@@ -16,7 +16,7 @@ def what_platform() -> SUPPORTED_PLATFORMS:
     """
     Returns what platform/OS this device is running on.
 
-    E.g. Windows, Linux, Android, Darwin, iOS
+    E.g. Windows, Linux, FreeBSD, Android, Darwin, iOS
     """
     os = platform.system()
 
@@ -47,4 +47,4 @@ def what_distro() -> str | None:
 
         return RELEASE_DATA["ID"]    
 
-    return None
\ No newline at end of file
+    return None
@nxjosephofficial nxjosephofficial added the bug Something isn't working label Sep 22, 2024
@nxjosephofficial
Copy link
Author
nxjosephofficial commented Sep 22, 2024

I just made a patch adding FreeBSD platform to players/mpv.py and i got it working!!!!

2024-09-22-230539_1366x768_scrot

It seems like i should add FreeBSD whenever i see a platforms list. It would be nice if you could tell me which files should i edit to add FreeBSD. Or maybe i can find platform lists with grep.

@r3tr0ananas
Copy link
Member

I just published a new version (4.4.13) which adds FreeBSD support. af78942

@nxjosephofficial
Copy link
Author

Oh, that's nice! Thanks for this quick job! I'll let you know when I test the new release.

@nxjosephofficial
Copy link
Author
nxjosephofficial commented Sep 22, 2024

It does seem to work, thanks. ❤️ I submitted all the ports i've made to get mov-cli working. I hope they eventually will be available in FreeBSD ports tree soon, until then you can use my personal ports repository on GitHub.

@nxjosephofficial nxjosephofficial changed the title [BUG] AttributeError: 'NoneType' object has no attribute 'args' [BUG] FreeBSD Support Sep 22, 2024
@THEGOLDENPRO
Copy link
Member

I didn't imagine mov-cli would work on FreeBSD.

Nice job ✨

@nxjosephofficial
Copy link
Author
nxjosephofficial commented Sep 23, 2024

Thanks. I think we can port software to FreeBSD that didn't build especially for Linux and not contain hard to solve linuxisms.

I'm glad this worked on FreeBSD too.

Now, I got youtube thumbnail preview working too. It was easy because required dependency for preview chafa is already available in FreeBSD.

2024-09-23-142449_1366x768_scrot

--- mov_cli/dev_cli/preview.py.orig     2024-09-23 11:22:25 UTC
+++ mov_cli/dev_cli/preview.py
@@ -29,7 +29,7 @@ def image(id: str):
 def image(id: str):
     platform = what_platform()

-    if not platform == "Linux" and not platform == "Android":
+    if not platform == "Linux" and not platform == "FreeBSD" and not platform == "Android":
         print("Image preview only works on Linux, FreeBSD & Android atm.")
         return False

@@ -102,4 +102,4 @@ def slugify(value): # https://github.com/django/django
     )

     value = re.sub(r"[^\w\s-]", "", value.lower())
-    return re.sub(r"[-\s]+", "-", value).strip("-_")
\ No newline at end of file
+    return re.sub(r"[-\s]+", "-", value).strip("-_")

@nxjosephofficial
Copy link
Author

I created ports for other plugins too and submitted them to FreeBSD. They will be available in FreeBSD repositories once they are commited to the FreeBSD ports tree.

image

@THEGOLDENPRO THEGOLDENPRO reopened this Sep 23, 2024
@THEGOLDENPRO
Copy link
Member

Thanks, correcting that now

@nxjosephofficial
Copy link
Author

You are welcome, i can make a PR about it if you want.

@THEGOLDENPRO
Copy link
Member

You are welcome, i can make a PR about it if you want.

Already created a commit but yeah next time feel free to open a PR instead.

@THEGOLDENPRO
Copy link
Member
THEGOLDENPRO commented Sep 23, 2024

Could you test the latest commit so I can confirm that it works correctly on FreeBSD.

pip install git+https://github.com/mov-cli/mov-cli -U

something like that should work to install it

@nxjosephofficial
Copy link
Author
nxjosephofficial commented Sep 23, 2024

I tested it and it works but you may want to change the printed text to include FreeBSD too.

dcaa671#diff-b13718547c0203d21f2f39c81b03af1413df8198547883cd411cdd3a5b2c44fbR33

I can update mov-cli port once new release published including this commit. Until then, my patch can stay in the port to enable preview.

@THEGOLDENPRO
Copy link
Member

I've now released v4.4.14, once again thanks.

@THEGOLDENPRO
Copy link
Member

Anymore issues, open another git issue and feel free to make a pr. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants