diff --git a/YouTubeMDBot/__init__.py b/YouTubeMDBot/__init__.py
index d0c79d3..e9bdb16 100644
--- a/YouTubeMDBot/__init__.py
+++ b/YouTubeMDBot/__init__.py
@@ -13,11 +13,4 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from .bot import PROGRAM_ARGS
-from .bot import main
-from .logging_utils import LoggingHandler
-from .logging_utils import setup_logging
-
-from .decorators import send_action
-from .decorators import restricted
diff --git a/YouTubeMDBot/audio/__init__.py b/YouTubeMDBot/audio/__init__.py
new file mode 100644
index 0000000..5544681
--- /dev/null
+++ b/YouTubeMDBot/audio/__init__.py
@@ -0,0 +1,16 @@
+# YouTubeMDBot
+# Copyright (C) 2019 - Javinator9889
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+from ..audio.audio_utils import AudioUtils
diff --git a/YouTubeMDBot/audio/audio_utils.py b/YouTubeMDBot/audio/audio_utils.py
new file mode 100644
index 0000000..1dc5525
--- /dev/null
+++ b/YouTubeMDBot/audio/audio_utils.py
@@ -0,0 +1,38 @@
+# YouTubeMDBot
+# Copyright (C) 2019 - Javinator9889
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+from io import BytesIO
+
+import soundfile
+
+
+class AudioUtils(object):
+ def __init__(self, audio: BytesIO):
+ self.__audio = soundfile.SoundFile(audio)
+
+ def get_audio_samplerate(self) -> int:
+ return self.__audio.samplerate
+
+ def get_audio_channels(self) -> int:
+ return self.__audio.channels
+
+ def get_audio_duration(self) -> float:
+ return self.__audio.frames / self.get_audio_samplerate()
+
+ def get_audio_name(self) -> str:
+ return self.__audio.name
+
+ def get_audio_format(self) -> str:
+ return self.__audio.format
diff --git a/YouTubeMDBot/commands/StartHandler.py b/YouTubeMDBot/commands/StartHandler.py
index d209a1e..8d18c8e 100644
--- a/YouTubeMDBot/commands/StartHandler.py
+++ b/YouTubeMDBot/commands/StartHandler.py
@@ -13,7 +13,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from .. import LoggingHandler
class StartHandler(object):
@@ -21,4 +20,5 @@ def __init__(self):
self._user_data = {}
def start(self, bot, update):
- self._user_data[]
+ pass
+ # TODO
diff --git a/YouTubeMDBot/decorators/decorators.py b/YouTubeMDBot/decorators/decorators.py
index b378e01..ab6f59e 100644
--- a/YouTubeMDBot/decorators/decorators.py
+++ b/YouTubeMDBot/decorators/decorators.py
@@ -48,7 +48,6 @@ def restricted(func):
def wrapped(update, context, *args, **kwargs):
user_id = update.effective_user.id
if user_id not in PROGRAM_ARGS["admin"]:
- logging.warning("Unauthorized access denied for {}.".format(user_id))
return
return func(update, context, *args, **kwargs)
return wrapped
diff --git a/YouTubeMDBot/metadata/MetadataIdentifier.py b/YouTubeMDBot/metadata/MetadataIdentifier.py
index b473a23..26477f9 100644
--- a/YouTubeMDBot/metadata/MetadataIdentifier.py
+++ b/YouTubeMDBot/metadata/MetadataIdentifier.py
@@ -13,8 +13,24 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+from io import BytesIO
+
import acoustid
+from .. import AudioUtils
+
class MetadataIdentifier(object):
- def __init__(self, filename: str = None, audio: str = None):
+ def __init__(self, audio: BytesIO, raw: bytes):
+ self.__audio = raw
+ self.__audio_info = AudioUtils(audio)
+
+ def _calculate_fingerprint(self) -> bytes:
+ return acoustid.fingerprint(self.__audio_info.get_audio_samplerate(),
+ self.__audio_info.get_audio_channels(),
+ iter(self.__audio))
+
+ def identify_audio(self) -> list:
+ fingerprint = self._calculate_fingerprint()
+ return acoustid.lookup(None, fingerprint,
+ self.__audio_info.get_audio_duration())
diff --git a/YouTubeMDBot/requirements.txt b/YouTubeMDBot/requirements.txt
index 9c3d398..927b4d0 100644
--- a/YouTubeMDBot/requirements.txt
+++ b/YouTubeMDBot/requirements.txt
@@ -1,3 +1,4 @@
+SoundFile
youtube_dl
pyacoustid
python-telegram-bot