Repository: CodeWithEmad/apyrat

Issue:
prompt when confirm flag is and quality is not provided
if quality is not provided prompt is always used, which is not desirable when batch downloading and only best quality is desired:
https://github.com/CodeWithEmad/apyrat/blob/50409df64ee87706832adbe459f283a60d7b6638/apyrat/cli.py#L82-L89

something like this would be better imo:
```python
if not quality:
    if confirm:
        return downloader.default_quality()
    else:
        ...
```

Discussion:

Patch:
diff --git a/apyrat/cli.py b/apyrat/cli.py
index 34bb93f..d891588 100644
--- a/apyrat/cli.py
+++ b/apyrat/cli.py
@@ -1,7 +1,8 @@
 """Console script for apyrat."""
+
 import click
 
-from apyrat.apyrat import Downloader, URLType
+from apyrat.apyrat import Downloader, URLType, VideoQuality
 from apyrat.utils import get_about_information
 
 
@@ -54,7 +55,7 @@ def display_help(ctx, param, value):
 )
 @click.argument("url", type=str, required=True)
 @click.pass_context
-def main(ctx, url, quality, filename, confirm):
+def main(ctx, url: str, quality: str, filename: str, confirm: bool):
     """
     Download Aparat videos from your terminal
     """
@@ -68,16 +69,22 @@ def main(ctx, url, quality, filename, confirm):
     if filename and downloader.url_type == URLType.VIDEO:
         downloader.file_name = filename
 
-    quality_choice = get_quality(downloader, quality, confirm)
+    quality_choice = str(
+        downloader.default_quality()
+        if confirm
+        else get_quality(
+            downloader,
+            quality,
+        )
+    )
 
     downloader.download(quality_choice)
 
 
-def get_quality(downloader, quality, confirm):
+def get_quality(downloader: Downloader, quality: VideoQuality):
     if quality and quality not in downloader.qualities:
         click.echo(f"Quality {quality} is not available", err=True)
-        if not confirm:
-            quality = None
+        quality = None
 
     if not quality:
         quality_choice = click.prompt(


Test patch:
diff --git a/tests/cli_test.py b/tests/cli_test.py
index b7c25ee..d98bf95 100644
--- a/tests/cli_test.py
+++ b/tests/cli_test.py
@@ -36,18 +36,18 @@ def test_get_quality_available():
     downloader = Downloader("https://www.aparat.com/v/qur3I")
     downloader.qualities = ["480", "720", "1080"]
     with patch("click.prompt", return_value="720"):
-        assert get_quality(downloader, "720", True) == "720"
+        assert get_quality(downloader, "720") == "720"
 
 
 def test_get_quality_not_available():
     downloader = Downloader("https://www.aparat.com/v/qur3I")
     downloader.qualities = ["480", "720", "1080"]
     with patch("click.prompt", return_value="720"):
-        assert get_quality(downloader, "240", False) == "720"
+        assert get_quality(downloader, "240") == "720"
 
 
 def test_get_quality_not_available_no_confirm():
     downloader = Downloader("https://www.aparat.com/v/qur3I")
     downloader.qualities = ["480", "720", "1080"]
     with patch("click.prompt", return_value="480"):
-        assert get_quality(downloader, "240", False) == "480"
+        assert get_quality(downloader, "240") == "480"