Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Definition of functions that are used to interact with youtube."""
import requests
from bs4 import BeautifulSoup
import os
import youtube_dl
import re
from ytmdl import defaults, utility, stringutils
from downloader_cli.download import Download
import traceback
from ytmdl.logger import Logger
logger = Logger("yt")
def get_youtube_streams(url):
"""Get both audio & video stream urls for youtube using youtube-dl.
PS: I don't know how youtube-dl does the magic
"""
cli = "youtube-dl -g {}".format(url)
output, error = utility.exe(cli)
stream_urls = output.split("\n")
url = stream_urls[1]
return url
def get_audio_URL(link, proxy):
"""Definition of functions that are used to interact with youtube."""
import requests
from bs4 import BeautifulSoup
import os
import youtube_dl
import re
from ytmdl import defaults, utility, stringutils
from downloader_cli.download import Download
import traceback
from ytmdl.logger import Logger
logger = Logger("yt")
def get_youtube_streams(url):
"""Get both audio & video stream urls for youtube using youtube-dl.
PS: I don't know how youtube-dl does the magic
"""
cli = "youtube-dl -g {}".format(url)
output, error = utility.exe(cli)
stream_urls = output.split("\n")
url = stream_urls[1]
return url
def get_audio_URL(link, proxy):
# Following is an example of the format\n\
#SONG_DIR = "/home/deepjyoti30/Music$Artist->Album->Title"\n\
#\n\
#*****************************************#\n\
# The QUALITY is the quality of the song in kbps\n\
# By default it is set to 320kbps\n\
# In case you want to change it to something else,\n\
# Uncomment the following line and change it\n\
#\n\
# Supported values are 320 and 192\n\
#\n\
#QUALITY = "320"\n\
#'
logger = Logger("config")
class DEFAULTS:
"""Some default stuff defined."""
def __init__(self):
# The home dir
self.HOME_DIR = os.path.expanduser('~')
# The default song dir
self.SONG_DIR = self._get_music_dir()
# The temp dir
self.SONG_TEMP_DIR = os.path.join(self.SONG_DIR, 'ytmdl')
# The default song quality
Nishan Pantha(c) 2017-18
NISH1001@github.com
"""
import glob
import os
from ytmdl.stringutils import (
remove_multiple_spaces, remove_punct, compute_jaccard, remove_stopwords,
check_keywords
)
from ytmdl.defaults import DEFAULT
from ytmdl.prepend import PREPEND
from ytmdl.logger import Logger
from colorama import Fore, Style
logger = Logger("cache")
class Cache:
"""The main caching component."""
def __init__(self, directory=None):
"""Init the stuff."""
if directory is None:
directory = DEFAULT.SONG_DIR
# Check the dir only if special characters are present
if '$' in directory:
directory = os.path.dirname(directory)
directory = os.path.expanduser(directory)
self.directory = directory
def list_mp3(self):