Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
YouTubeMDBot
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
12
Issues
12
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Javinator9889
YouTubeMDBot
Commits
6e6ade3d
Verified
Commit
6e6ade3d
authored
Oct 14, 2019
by
Javinator9889
🎼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pylint improvement - completed API and ffmpeg audio classes & methods
parent
e55eb1a7
Pipeline
#88
failed with stage
in 27 minutes and 49 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
3 deletions
+41
-3
YouTubeMDBot/audio/fpcalc.py
YouTubeMDBot/audio/fpcalc.py
+21
-1
YouTubeMDBot/constants/__init__.py
YouTubeMDBot/constants/__init__.py
+1
-0
YouTubeMDBot/constants/app_constants.py
YouTubeMDBot/constants/app_constants.py
+2
-0
YouTubeMDBot/decorators/decorators.py
YouTubeMDBot/decorators/decorators.py
+1
-1
YouTubeMDBot/downloader/youtube_downloader.py
YouTubeMDBot/downloader/youtube_downloader.py
+16
-1
No files found.
YouTubeMDBot/audio/fpcalc.py
View file @
6e6ade3d
...
...
@@ -21,6 +21,10 @@ from ..constants import FPCALC
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 @@ class FPCalc(object):
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
YouTubeMDBot/constants/__init__.py
View file @
6e6ade3d
...
...
@@ -17,5 +17,6 @@ from ..constants.app_constants import ACOUSTID_KEY
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
YouTubeMDBot/constants/app_constants.py
View file @
6e6ade3d
...
...
@@ -14,7 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
os
import
sys
PROGRAM_ARGS
=
sys
.
argv
# YouTube DL options
YDL_CLI_OPTIONS
=
[
"youtube-dl"
,
"--format"
,
"bestaudio[ext=m4a]"
,
"--quiet"
,
"--output"
,
"-"
]
...
...
YouTubeMDBot/decorators/decorators.py
View file @
6e6ade3d
...
...
@@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
functools
import
wraps
from
..
import
PROGRAM_ARGS
from
..
constants
import
PROGRAM_ARGS
# logging = LoggingHandler()
...
...
YouTubeMDBot/downloader/youtube_downloader.py
View file @
6e6ade3d
...
...
@@ -19,13 +19,24 @@ from typing import Tuple
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 @@ class YouTubeDownloader(object):
str
(
stderr
.
decode
(
"utf-8"
)))
def
get_url
(
self
)
->
str
:
"""
Obtains the video URL.
:return: str with the URL.
"""
return
self
.
__url
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment