コード例 #1
0
ファイル: trim.py プロジェクト: xcodeuuuuu66699/ytmdl
"""
Handle the stuff related to trimming the song
in order to remove the speech.
"""

from inaSpeechSegmenter import Segmenter
from warnings import filterwarnings
from os import environ, remove, rename
import ffmpeg
from ytmdl.logger import Logger

# Setup the logger name
logger = Logger("Trimmer")


# Remove the warnings from tensorflow
environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
# Ignore warnings
filterwarnings("ignore")


class Trim:
    """
    Class that will handle the processing of the files.

    filename: File that we want to process.

    We will run the speech segmenter on it and get
    the music timestamps. Once we have the stamps, we can just
    trim the music part from the song and keep the name same.
    """
コード例 #2
0
ファイル: utility.py プロジェクト: repoarchiver/ytmdl
"""Some definitions to interact with the command line."""

import subprocess
from os import remove, path, popen
from ytmdl import defaults, stringutils
from shutil import which
import ffmpeg

from ytmdl.logger import Logger

logger = Logger("Utility")


def exe(command):
    """Execute the command externally.

    Written by Nishan Pantha.
    """
    command = command.strip()
    c = command.split()
    output, error = subprocess.Popen(c,
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.PIPE).communicate()
    output = output.decode('utf-8').strip()
    error = error.decode('utf-8').strip()
    return (output, error)


def get_terminal_length():
    """Return the length of the terminal."""
    rows, cols = popen('stty size', 'r').read().split()
コード例 #3
0
ファイル: yt.py プロジェクト: ReubenScott/ytmdl
"""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 sys import stdout
from youtube_search import YoutubeSearch

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

コード例 #4
0
#
#*****************************************#
# The METADATA_PROVIDERS value is a comma separated
# values that specifies wich API providers to use for getting
# the song metadata. Available values right now are:
# itunes, gaana, deezer, lastfm. saavn.
# Please check the github page of ytmdl for more information.
#
#METADATA_PROVIDERS = "itunes, gaana"
#*****************************************#
# The DEFAULT_FORMAT denotes what to use as default between
# m4a and mp3
#DEFAULT_FORMAT = "mp3"
#'''

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