Download link: from generating to finding
So now you can download ANY song using this utility!
This commit is contained in:
parent
10612f0809
commit
081b8e897d
Binary file not shown.
@ -4,6 +4,7 @@ from bs4 import BeautifulSoup as parse
|
|||||||
import click
|
import click
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.argument('songid',nargs=1,metavar='<Newgrounds song ID>')
|
@click.argument('songid',nargs=1,metavar='<Newgrounds song ID>')
|
||||||
@click.option('-d','--dist',default='./Downloads',type=click.Path(exists=True),help='Where to save the songs (default: ./Downloads)')
|
@click.option('-d','--dist',default='./Downloads',type=click.Path(exists=True),help='Where to save the songs (default: ./Downloads)')
|
||||||
@ -13,21 +14,15 @@ def CLI(songid,dist):
|
|||||||
page=parse(load(f'https://www.newgrounds.com/audio/listen/{songid}').text,'html.parser')
|
page=parse(load(f'https://www.newgrounds.com/audio/listen/{songid}').text,'html.parser')
|
||||||
songTitle=page.find('title').text
|
songTitle=page.find('title').text
|
||||||
|
|
||||||
print('Creating download link...')
|
print('Searching download link...')
|
||||||
link=f'http://audio.ngfiles.com/{songid[:3]}000/{songid}_'
|
link='http://audio.ngfiles.com/'
|
||||||
count=0
|
page=str(page)
|
||||||
for char in songTitle:
|
i=page.find('audio.ngfiles.com')+len('audio.ngfiles.com/')
|
||||||
if 97<=ord(char.lower())<=122:
|
while not link.endswith('.mp3'):
|
||||||
link+=char
|
if page[i]!='\\': link+=page[i]
|
||||||
count+=1
|
i+=1
|
||||||
elif char==' ':
|
|
||||||
link+='-'
|
|
||||||
count+=1
|
|
||||||
if count==26: break
|
|
||||||
link+='.mp3'
|
|
||||||
|
|
||||||
if not access(dist,F_OK): mkdir(dist)
|
if not access(dist,F_OK): mkdir(dist)
|
||||||
|
|
||||||
print(f'Downloading "{songTitle}"...')
|
print(f'Downloading "{songTitle}"...')
|
||||||
download(link,dist)
|
download(link,dist)
|
||||||
print(f'"{songTitle}" successfully downloaded.')
|
print(f'"{songTitle}" successfully downloaded.')
|
||||||
|
|||||||
@ -24,7 +24,3 @@ Options:
|
|||||||
-d, --dist PATH Where to save the songs (default: ./Downloads)
|
-d, --dist PATH Where to save the songs (default: ./Downloads)
|
||||||
--help Show this message and exit.
|
--help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
## ※NOTE!
|
|
||||||
|
|
||||||
Please note that you can download the songs named with *latin symbols only*. I'll fix it later so just for now bear with what we have. :3
|
|
||||||
Reference in New Issue
Block a user