implement custom useragent flag

This commit is contained in:
aisuneko 2021-07-02 23:23:07 +08:00
parent 60403701ea
commit c172937fcb
No known key found for this signature in database
GPG Key ID: D546015BE70DC955
1 changed files with 8 additions and 1 deletions

View File

@ -9,10 +9,11 @@ from ncm.downloader import get_song_info_by_id
from ncm.downloader import download_song_by_id from ncm.downloader import download_song_by_id
from ncm.downloader import download_song_by_song from ncm.downloader import download_song_by_song
from ncm.downloader import format_string from ncm.downloader import format_string
from ncm.constants import headers
# load the config first # load the config first
config.load_config() config.load_config()
api = CloudApi() #api = CloudApi()
def download_hot_songs(artist_id): def download_hot_songs(artist_id):
@ -64,7 +65,12 @@ def main():
help='Download an album all songs by album_id') help='Download an album all songs by album_id')
parser.add_argument('-p', metavar='playlist_id', dest='playlist_id', parser.add_argument('-p', metavar='playlist_id', dest='playlist_id',
help='Download a playlist all songs by 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() args = parser.parse_args()
if args.user_agent:
headers.update({'User-Agent':args.user_agent})
#api = CloudApi()
if args.song_id: if args.song_id:
download_song_by_id(get_parse_id(args.song_id), config.DOWNLOAD_DIR) download_song_by_id(get_parse_id(args.song_id), config.DOWNLOAD_DIR)
elif args.song_ids: elif args.song_ids:
@ -80,3 +86,4 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()