mirror of
https://github.com/cooperhammond/irs.git
synced 2024-12-22 17:35:28 +00:00
Merge pull request #31 from kepoorhampond/better-organization-of-setup
Make sure to call `irs --setup` before anything else
This commit is contained in:
commit
da7137846f
|
@ -7,6 +7,7 @@ python:
|
|||
install:
|
||||
- pip install -r requirements.txt
|
||||
- python setup.py install
|
||||
- irs --setup
|
||||
|
||||
script:
|
||||
- python tests/album.py
|
||||
|
|
|
@ -16,13 +16,15 @@ A tool to download your music with metadata. It uses [Spotify](https://www.spoti
|
|||
|
||||
Works with Python 2 and 3.
|
||||
|
||||
## Install
|
||||
## Install and Setup
|
||||
```
|
||||
$ sudo pip install irs
|
||||
$ irs --setup
|
||||
```
|
||||
|
||||
**You will need to have some Spotify tokens, the instructions to set them up are [here](https://github.com/kepoorhampond/irs#spotify-tokens).**
|
||||
|
||||
|
||||
## Demo and Usages
|
||||
|
||||
This is a demo of the CLI displayling its features:
|
||||
|
|
|
@ -1 +1,20 @@
|
|||
from .ripper import Ripper
|
||||
import os
|
||||
import argparse
|
||||
from .setup_binaries import setup
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument("-S", "--setup", dest="setup", help="Setup IRS",
|
||||
action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.setup:
|
||||
setup()
|
||||
exit(0)
|
||||
elif not os.path.isdir(os.path.expanduser("~/.irs")):
|
||||
print("Please run `irs --setup` to install the youtube-dl and \
|
||||
ffmpeg binaries.")
|
||||
else:
|
||||
from .ripper import Ripper
|
||||
Ripper # PyLinter reasons
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
import sys
|
||||
from os import path
|
||||
|
||||
if path.isfile(path.expanduser("~/.irs/config_.py")):
|
||||
sys.path.append(path.expanduser("~/.irs")) # Add config to path
|
||||
|
||||
sys.path.append(path.expanduser("~/.irs")) # Add config to path
|
||||
import config_ # from "~/.irs/config_.py"
|
||||
|
||||
import config_ # from "~/.irs/config_.py"
|
||||
|
||||
CONFIG = config_.CONFIG
|
||||
CONFIG = config_.CONFIG
|
||||
else:
|
||||
config = open("irs/config_preset", "r").read()
|
||||
print(config)
|
||||
CONFIG = eval(config)
|
||||
|
|
|
@ -12,6 +12,7 @@ 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
|
||||
|
||||
|
|
12
irs/setup_binaries.py
Normal file
12
irs/setup_binaries.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
import ydl_binaries
|
||||
from shutil import copyfile
|
||||
import os
|
||||
|
||||
|
||||
def setup():
|
||||
ydl_binaries.download_ffmpeg("~/.irs/bin")
|
||||
ydl_binaries.update_ydl("~/.irs/bin")
|
||||
|
||||
config_file = os.path.expanduser("~/.irs/config_.py")
|
||||
if not os.path.isfile(config_file):
|
||||
copyfile("irs/config_preset", config_file)
|
39
setup.py
39
setup.py
|
@ -1,39 +1,4 @@
|
|||
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
|
||||
|
||||
try:
|
||||
import ydl_binaries
|
||||
except ImportError:
|
||||
import pip
|
||||
pip.main(['install', "ydl-binaries"])
|
||||
|
||||
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',
|
||||
|
@ -54,8 +19,4 @@ setup(
|
|||
entry_points = {
|
||||
'console_scripts': ['irs = irs.cli:main'],
|
||||
},
|
||||
cmdclass = {
|
||||
'develop': PostDevelopCommand,
|
||||
'install': PostInstallCommand,
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue