mirror of
https://github.com/cooperhammond/irs.git
synced 2024-12-31 18:55: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/
|
/*.egg-info/
|
||||||
/build/
|
/build/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
.eggs
|
||||||
|
|
||||||
# For easy updating of stuff.
|
# For easy updating of stuff.
|
||||||
update_pypi_and_github.py
|
update_pypi_and_github.py
|
||||||
|
@ -21,4 +22,4 @@ update_pypi_and_github.py
|
||||||
.coverage
|
.coverage
|
||||||
|
|
||||||
# Temporarily built binaries
|
# Temporarily built binaries
|
||||||
ffmpeg binaries/
|
ffmpeg binaries/
|
||||||
|
|
|
@ -4,12 +4,6 @@ python:
|
||||||
- "3.5"
|
- "3.5"
|
||||||
- "3.6"
|
- "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:
|
install:
|
||||||
- python setup.py 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"
|
# remove all keys with the value of "None"
|
||||||
ripper_args.update(vars(args))
|
ripper_args.update(vars(args))
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,8 @@
|
||||||
CONFIG = dict(
|
import sys
|
||||||
|
from os import path
|
||||||
|
|
||||||
default_flags = ['-o'],
|
sys.path.append(path.expanduser("~/.irs")) # Add config to path
|
||||||
# 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 = '',
|
import config_ # from "~/.irs/config_.py"
|
||||||
SPOTIFY_CLIENT_SECRET = '',
|
|
||||||
# You can either specify Spotify keys here, or in environment variables.
|
|
||||||
|
|
||||||
additional_search_terms = 'lyrics',
|
CONFIG = config_.CONFIG
|
||||||
# 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'
|
|
||||||
)
|
|
||||||
|
|
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
|
# System
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import glob
|
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
|
# Local utilities
|
||||||
from .utils import YdlUtils, ObjManip, Config
|
from .utils import YdlUtils, ObjManip, Config
|
||||||
from .metadata import Metadata
|
from .metadata import Metadata
|
||||||
|
@ -391,6 +396,7 @@ init, or in method arguments.")
|
||||||
'progress_hooks': [YdlUtils.my_hook],
|
'progress_hooks': [YdlUtils.my_hook],
|
||||||
'output': "tmp_file",
|
'output': "tmp_file",
|
||||||
'prefer-ffmpeg': True,
|
'prefer-ffmpeg': True,
|
||||||
|
'ffmpeg_location': os.path.expanduser("~/.irs/bin/")
|
||||||
}
|
}
|
||||||
|
|
||||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||||
|
|
|
@ -15,7 +15,8 @@ from time import sleep
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
# Config File and Flags
|
# 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 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(
|
setup(
|
||||||
name = 'irs',
|
name = 'irs',
|
||||||
|
@ -9,14 +38,18 @@ setup(
|
||||||
author_email = 'kepoorh@gmail.com',
|
author_email = 'kepoorh@gmail.com',
|
||||||
license = 'GPL',
|
license = 'GPL',
|
||||||
packages = ['irs'],
|
packages = ['irs'],
|
||||||
install_requires=[
|
install_requires = [
|
||||||
'bs4',
|
'bs4',
|
||||||
'mutagen',
|
'mutagen',
|
||||||
'youtube-dl',
|
|
||||||
'requests',
|
'requests',
|
||||||
'spotipy',
|
'spotipy',
|
||||||
|
'ydl-binaries'
|
||||||
],
|
],
|
||||||
entry_points = {
|
entry_points = {
|
||||||
'console_scripts': ['irs = irs.cli:main'],
|
'console_scripts': ['irs = irs.cli:main'],
|
||||||
},
|
},
|
||||||
|
cmdclass = {
|
||||||
|
'develop': PostDevelopCommand,
|
||||||
|
'install': PostInstallCommand,
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue