diff --git a/YouTubeMDBot/audio/fpcalc.py b/YouTubeMDBot/audio/fpcalc.py
index d4833fc..5629b12 100755
--- a/YouTubeMDBot/audio/fpcalc.py
+++ b/YouTubeMDBot/audio/fpcalc.py
@@ -21,6 +21,10 @@
def is_fpcalc_available() -> bool:
+ """
+ Checks if ffmpeg is installed in the system.
+ :return: True if available, else False.
+ """
try:
proc = Popen(["fpcalc", "-v"], stdout=PIPE, stderr=PIPE)
except OSError:
@@ -29,8 +33,16 @@ def is_fpcalc_available() -> bool:
proc.wait()
-class FPCalc(object):
+class FPCalc:
+ """
+ Calculates audio fingerprint by passing the audio bytes.
+ It operates with pipes so no file is created.
+ """
def __init__(self, audio: bytes):
+ """
+ Creates the FPCalc object.
+ :param audio: the audio bytes.
+ """
fpcalc = Popen(FPCALC, stdout=PIPE, stdin=PIPE)
out, _ = fpcalc.communicate(audio)
res = out.decode("utf-8")
@@ -44,7 +56,15 @@ def __init__(self, audio: bytes):
self.__fp: str = str(fingerprint.group(0))
def duration(self) -> int:
+ """
+ Obtains the audio duration in seconds.
+ :return: duration in seconds.
+ """
return self.__duration
def fingerprint(self) -> str:
+ """
+ Obtains the audio fingerprint.
+ :return: fingerprint in seconds.
+ """
return self.__fp
diff --git a/YouTubeMDBot/constants/__init__.py b/YouTubeMDBot/constants/__init__.py
index 60906a2..12af4b1 100755
--- a/YouTubeMDBot/constants/__init__.py
+++ b/YouTubeMDBot/constants/__init__.py
@@ -17,5 +17,6 @@
from ..constants.app_constants import FPCALC
from ..constants.app_constants import YDL_CLI_OPTIONS
from ..constants.app_constants import YOUTUBE
+from ..constants.app_constants import PROGRAM_ARGS
from ..constants.app_constants import FFMPEG_OPENER
from ..constants.app_constants import FFMPEG_CONVERTER
diff --git a/YouTubeMDBot/constants/app_constants.py b/YouTubeMDBot/constants/app_constants.py
index 5564c27..1ef1e70 100755
--- a/YouTubeMDBot/constants/app_constants.py
+++ b/YouTubeMDBot/constants/app_constants.py
@@ -14,7 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
import os
+import sys
+PROGRAM_ARGS = sys.argv
# YouTube DL options
YDL_CLI_OPTIONS = ["youtube-dl", "--format", "bestaudio[ext=m4a]", "--quiet", "--output",
"-"]
diff --git a/YouTubeMDBot/decorators/decorators.py b/YouTubeMDBot/decorators/decorators.py
index ab6f59e..71b67ac 100755
--- a/YouTubeMDBot/decorators/decorators.py
+++ b/YouTubeMDBot/decorators/decorators.py
@@ -15,7 +15,7 @@
# along with this program. If not, see .
from functools import wraps
-from .. import PROGRAM_ARGS
+from ..constants import PROGRAM_ARGS
# logging = LoggingHandler()
diff --git a/YouTubeMDBot/downloader/youtube_downloader.py b/YouTubeMDBot/downloader/youtube_downloader.py
index 6139205..69c8edb 100755
--- a/YouTubeMDBot/downloader/youtube_downloader.py
+++ b/YouTubeMDBot/downloader/youtube_downloader.py
@@ -19,13 +19,24 @@
from ..constants.app_constants import YDL_CLI_OPTIONS
-class YouTubeDownloader(object):
+class YouTubeDownloader:
+ """
+ Download a YouTube video directly into memory.
+ """
def __init__(self, url: str):
+ """
+ Creates the YouTubeDownloader object. Call "download" for obtaining the video.
+ :param url: the video URL.
+ """
self.__url: str = url
self.__options: list = YDL_CLI_OPTIONS.copy()
self.__options.append(self.__url)
def download(self) -> Tuple[BytesIO, bytes]:
+ """
+ Downloads the YouTube video directly into memory by using pipes.
+ :return: a tuple with "BytesIO" and "bytes".
+ """
import subprocess
proc = subprocess.Popen(self.__options,
@@ -40,4 +51,8 @@ def download(self) -> Tuple[BytesIO, bytes]:
str(stderr.decode("utf-8")))
def get_url(self) -> str:
+ """
+ Obtains the video URL.
+ :return: str with the URL.
+ """
return self.__url