Update package name to 'ncm', and add setuptools.
This commit is contained in:
parent
b29c52df47
commit
d810377d9f
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from encrypt import encrypted_request
|
from ncm.encrypt import encrypted_request
|
||||||
from constants import headers
|
from ncm.constants import headers
|
||||||
from constants import song_download_url
|
from ncm.constants import song_download_url
|
||||||
from constants import get_song_url
|
from ncm.constants import get_song_url
|
||||||
from constants import get_album_url
|
from ncm.constants import get_album_url
|
||||||
from constants import get_artist_url
|
from ncm.constants import get_artist_url
|
||||||
from constants import get_playlist_url
|
from ncm.constants import get_playlist_url
|
||||||
|
|
||||||
|
|
||||||
class CloudApi(object):
|
class CloudApi(object):
|
|
@ -3,8 +3,8 @@
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from api import CloudApi
|
from ncm.api import CloudApi
|
||||||
from file_util import add_metadata_to_song
|
from ncm.file_util import add_metadata_to_song
|
||||||
|
|
||||||
|
|
||||||
def download_song_by_id(song_id, download_folder):
|
def download_song_by_id(song_id, download_folder):
|
|
@ -6,7 +6,7 @@ import json
|
||||||
import binascii
|
import binascii
|
||||||
from Crypto.Cipher import AES
|
from Crypto.Cipher import AES
|
||||||
|
|
||||||
from constants import modulus, nonce, pub_key
|
from ncm.constants import modulus, nonce, pub_key
|
||||||
|
|
||||||
|
|
||||||
def encrypted_request(text):
|
def encrypted_request(text):
|
|
@ -1,32 +1,14 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import config
|
|
||||||
|
|
||||||
from api import CloudApi
|
from ncm import config
|
||||||
from downloader import download_song_by_id
|
from ncm.api import CloudApi
|
||||||
from downloader import download_song_by_song
|
from ncm.downloader import download_song_by_id
|
||||||
|
from ncm.downloader import download_song_by_song
|
||||||
|
|
||||||
# load the config first
|
# load the config first
|
||||||
config.load_config()
|
config.load_config()
|
||||||
print('max:', config.DOWNLOAD_HOT_MAX)
|
|
||||||
print('dir:', config.DOWNLOAD_DIR)
|
|
||||||
print('name_type:', config.SONG_NAME_TYPE)
|
|
||||||
print('folder_type:', config.SONG_FOLDER_TYPE)
|
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Welcome to netease cloud music downloader!')
|
|
||||||
parser.add_argument('-s', metavar='song_id', dest='song_id',
|
|
||||||
help='Download a song by song_id')
|
|
||||||
parser.add_argument('-ss', metavar='song_ids', dest='song_ids', nargs='+',
|
|
||||||
help='Download a song list, song_id split by space')
|
|
||||||
parser.add_argument('-hot', metavar='artist_id', dest='artist_id',
|
|
||||||
help='Download an artist hot 50 songs by artist_id')
|
|
||||||
parser.add_argument('-a', metavar='album_id', dest='album_id',
|
|
||||||
help='Download an album all songs by album_id')
|
|
||||||
parser.add_argument('-p', metavar='playlist_id', dest='playlist_id',
|
|
||||||
help='Download a playlist all songs by playlist_id')
|
|
||||||
args = parser.parse_args()
|
|
||||||
api = CloudApi()
|
api = CloudApi()
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,17 +39,34 @@ def download_playlist_songs(playlist_id):
|
||||||
download_song_by_song(song, folder_path)
|
download_song_by_song(song, folder_path)
|
||||||
|
|
||||||
|
|
||||||
if args.song_id:
|
def main():
|
||||||
download_song_by_id(args.song_id, config.DOWNLOAD_DIR)
|
parser = argparse.ArgumentParser(description='Welcome to netease cloud music downloader!')
|
||||||
elif args.song_ids:
|
parser.add_argument('-s', metavar='song_id', dest='song_id',
|
||||||
for song_id in args.song_ids:
|
help='Download a song by song_id')
|
||||||
download_song_by_id(song_id, config.DOWNLOAD_DIR)
|
parser.add_argument('-ss', metavar='song_ids', dest='song_ids', nargs='+',
|
||||||
elif args.artist_id:
|
help='Download a song list, song_id split by space')
|
||||||
download_hot_songs(args.artist_id)
|
parser.add_argument('-hot', metavar='artist_id', dest='artist_id',
|
||||||
elif args.album_id:
|
help='Download an artist hot 50 songs by artist_id')
|
||||||
download_album_songs(args.album_id)
|
parser.add_argument('-a', metavar='album_id', dest='album_id',
|
||||||
elif args.playlist_id:
|
help='Download an album all songs by album_id')
|
||||||
download_playlist_songs(args.playlist_id)
|
parser.add_argument('-p', metavar='playlist_id', dest='playlist_id',
|
||||||
|
help='Download a playlist all songs by playlist_id')
|
||||||
|
args = parser.parse_args()
|
||||||
|
if args.song_id:
|
||||||
|
download_song_by_id(args.song_id, config.DOWNLOAD_DIR)
|
||||||
|
elif args.song_ids:
|
||||||
|
for song_id in args.song_ids:
|
||||||
|
download_song_by_id(song_id, config.DOWNLOAD_DIR)
|
||||||
|
elif args.artist_id:
|
||||||
|
download_hot_songs(args.artist_id)
|
||||||
|
elif args.album_id:
|
||||||
|
download_album_songs(args.album_id)
|
||||||
|
elif args.playlist_id:
|
||||||
|
download_playlist_songs(args.playlist_id)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
||||||
# song = api.get_song('464035731')
|
# song = api.get_song('464035731')
|
24
setup.py
24
setup.py
|
@ -1,2 +1,26 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='netease-cloud-music-dl',
|
||||||
|
version='0.0.1',
|
||||||
|
packages=find_packages(),
|
||||||
|
install_requires=[
|
||||||
|
'requests>=2.17.3',
|
||||||
|
'pycrypto>=2.6.1',
|
||||||
|
'mutagen>=1.38.0',
|
||||||
|
],
|
||||||
|
|
||||||
|
entry_points={
|
||||||
|
'console_scripts': [
|
||||||
|
'ncm = ncm.start:main',
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
license='Apache License V2',
|
||||||
|
author='codezjx',
|
||||||
|
author_email='code.zjx@gmail.com',
|
||||||
|
url='https://github.com/codezjx/netease-cloud-music-dl',
|
||||||
|
description='Netease cloud music downloader, with full ID3 metadata!',
|
||||||
|
keywords=['ncm', 'cloud-music', 'downloader'],
|
||||||
|
)
|
Loading…
Reference in New Issue