Merge pull request #59 from aisuneko/master

New feature: option which enables the user to specify an user-agent
This commit is contained in:
codezjx 2022-07-14 20:35:47 +08:00 committed by GitHub
commit f6b480a9a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -9,6 +9,7 @@ from ncm.downloader import get_song_info_by_id
from ncm.downloader import download_song_by_id
from ncm.downloader import download_song_by_song
from ncm.downloader import format_string
from ncm.constants import headers
# load the config first
config.load_config()
@ -73,7 +74,11 @@ def main():
help='Download a program by program_id')
parser.add_argument('-p', metavar='playlist_id', dest='playlist_id',
help='Download a playlist all songs by playlist_id')
parser.add_argument('-ua', metavar='user_agent', dest='user_agent',
help='Specify the User-Agent to be used when downloading')
args = parser.parse_args()
if args.user_agent:
headers.update({'User-Agent':args.user_agent})
if args.song_id:
download_song_by_id(get_parse_id(args.song_id), config.DOWNLOAD_DIR)
elif args.song_ids:
@ -91,3 +96,4 @@ def main():
if __name__ == '__main__':
main()