mirror of
https://github.com/cooperhammond/irs.git
synced 2024-12-22 17:35:28 +00:00
Now automatically downloads youtube-dl, ffmpeg, and ffprobe binaries
This commit is contained in:
parent
48ad9ac19e
commit
8e6f76c312
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -4,6 +4,7 @@
|
|||
/*.egg-info/
|
||||
/build/
|
||||
__pycache__/
|
||||
.eggs
|
||||
|
||||
# For easy updating of stuff.
|
||||
update_pypi_and_github.py
|
||||
|
@ -21,4 +22,4 @@ update_pypi_and_github.py
|
|||
.coverage
|
||||
|
||||
# Temporarily built binaries
|
||||
ffmpeg binaries/
|
||||
ffmpeg binaries/
|
||||
|
|
|
@ -4,12 +4,6 @@ python:
|
|||
- "3.5"
|
||||
- "3.6"
|
||||
|
||||
before_script:
|
||||
- sudo aptitude -y -q install libav-tools
|
||||
# These dependencies are necessary for ffmpeg. I currently hate all things
|
||||
# doing with Travis and ffmpeg because I have no direct access to test stuff.
|
||||
# I've gone through 25 seperate commits to get it working.
|
||||
|
||||
install:
|
||||
- python setup.py install
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ directory to place files in.")
|
|||
}
|
||||
}
|
||||
|
||||
# Combiner args from argparse and the ripper_args as above and then
|
||||
# Combine args from argparse and the ripper_args as above and then
|
||||
# remove all keys with the value of "None"
|
||||
ripper_args.update(vars(args))
|
||||
|
||||
|
|
|
@ -1,24 +1,8 @@
|
|||
CONFIG = dict(
|
||||
import sys
|
||||
from os import path
|
||||
|
||||
default_flags = ['-o'],
|
||||
# For default flags. Right now, it organizes your files into an
|
||||
# artist/album/song structure.
|
||||
# To add a flag or argument, add an element to the index:
|
||||
# default_flags = ['-o', '-l', '~/Music']
|
||||
sys.path.append(path.expanduser("~/.irs")) # Add config to path
|
||||
|
||||
SPOTIFY_CLIENT_ID = '',
|
||||
SPOTIFY_CLIENT_SECRET = '',
|
||||
# You can either specify Spotify keys here, or in environment variables.
|
||||
import config_ # from "~/.irs/config_.py"
|
||||
|
||||
additional_search_terms = 'lyrics',
|
||||
# Search terms for youtube
|
||||
|
||||
organize = True,
|
||||
# True always forces organization.
|
||||
# False always forces non-organization.
|
||||
# None allows options and flags to determine if the files
|
||||
# will be organized.
|
||||
|
||||
custom_directory = "",
|
||||
# Defaults to '~/Music'
|
||||
)
|
||||
CONFIG = config_.CONFIG
|
||||
|
|
24
irs/config_preset
Normal file
24
irs/config_preset
Normal file
|
@ -0,0 +1,24 @@
|
|||
CONFIG = dict(
|
||||
|
||||
default_flags = ['-o'],
|
||||
# For default flags. Right now, it organizes your files into an
|
||||
# artist/album/song structure.
|
||||
# To add a flag or argument, add an element to the index:
|
||||
# default_flags = ['-o', '-l', '~/Music']
|
||||
|
||||
SPOTIFY_CLIENT_ID = '',
|
||||
SPOTIFY_CLIENT_SECRET = '',
|
||||
# You can either specify Spotify keys here, or in environment variables.
|
||||
|
||||
additional_search_terms = 'lyrics',
|
||||
# Search terms for youtube
|
||||
|
||||
organize = True,
|
||||
# True always forces organization.
|
||||
# False always forces non-organization.
|
||||
# None allows options and flags to determine if the files
|
||||
# will be organized.
|
||||
|
||||
custom_directory = "",
|
||||
# When blank, defaults to '~/Music'
|
||||
)
|
|
@ -1,13 +1,18 @@
|
|||
# Powered by:
|
||||
import youtube_dl
|
||||
import spotipy
|
||||
from spotipy.oauth2 import SpotifyClientCredentials
|
||||
|
||||
# System
|
||||
import sys
|
||||
import os
|
||||
import glob
|
||||
|
||||
|
||||
# Add youtube-dl binary to path
|
||||
sys.path.append(os.path.expanduser("~/.irs/bin/youtube-dl"))
|
||||
|
||||
# Powered by:
|
||||
import youtube_dl # Locally imported from the binary
|
||||
import spotipy
|
||||
from spotipy.oauth2 import SpotifyClientCredentials
|
||||
|
||||
|
||||
# Local utilities
|
||||
from .utils import YdlUtils, ObjManip, Config
|
||||
from .metadata import Metadata
|
||||
|
@ -391,6 +396,7 @@ init, or in method arguments.")
|
|||
'progress_hooks': [YdlUtils.my_hook],
|
||||
'output': "tmp_file",
|
||||
'prefer-ffmpeg': True,
|
||||
'ffmpeg_location': os.path.expanduser("~/.irs/bin/")
|
||||
}
|
||||
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
|
|
|
@ -15,7 +15,8 @@ from time import sleep
|
|||
import pkg_resources
|
||||
|
||||
# Config File and Flags
|
||||
from .config import CONFIG
|
||||
import config
|
||||
CONFIG = config.CONFIG
|
||||
|
||||
|
||||
# ==================
|
||||
|
|
37
setup.py
37
setup.py
|
@ -1,4 +1,33 @@
|
|||
from setuptools import setup
|
||||
from setuptools.command.develop import develop
|
||||
from setuptools.command.install import install
|
||||
|
||||
|
||||
class PostDevelopCommand(develop):
|
||||
"""Post-installation for development mode."""
|
||||
def run(self):
|
||||
# PUT YOUR PRE-INSTALL SCRIPT HERE or CALL A FUNCTION
|
||||
develop.run(self)
|
||||
# PUT YOUR POST-INSTALL SCRIPT HERE or CALL A FUNCTION
|
||||
|
||||
|
||||
class PostInstallCommand(install):
|
||||
"""Post-installation for installation mode."""
|
||||
def run(self):
|
||||
install.run(self) # Actually install the module and dependencies
|
||||
|
||||
import ydl_binaries
|
||||
from os import path
|
||||
from shutil import copyfile
|
||||
|
||||
print("\n\nDownloading Dependencies:\n")
|
||||
ydl_binaries.download_ffmpeg("~/.irs/bin")
|
||||
ydl_binaries.update_ydl("~/.irs/bin")
|
||||
|
||||
config_file = path.expanduser("~/.irs/config_.py")
|
||||
if not path.isfile(config_file):
|
||||
copyfile("irs/config_preset", config_file)
|
||||
|
||||
|
||||
setup(
|
||||
name = 'irs',
|
||||
|
@ -9,14 +38,18 @@ setup(
|
|||
author_email = 'kepoorh@gmail.com',
|
||||
license = 'GPL',
|
||||
packages = ['irs'],
|
||||
install_requires=[
|
||||
install_requires = [
|
||||
'bs4',
|
||||
'mutagen',
|
||||
'youtube-dl',
|
||||
'requests',
|
||||
'spotipy',
|
||||
'ydl-binaries'
|
||||
],
|
||||
entry_points = {
|
||||
'console_scripts': ['irs = irs.cli:main'],
|
||||
},
|
||||
cmdclass = {
|
||||
'develop': PostDevelopCommand,
|
||||
'install': PostInstallCommand,
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue