Initial commit
This commit is contained in:
commit
9cc8f2ff1c
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
__pycache__
|
||||||
|
/Downloads
|
||||||
33
NGAudioDownloader.py
Normal file
33
NGAudioDownloader.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from os import access,F_OK,mkdir
|
||||||
|
from requests import get as load
|
||||||
|
from bs4 import BeautifulSoup as parse
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
songId=input('Enter song id: ')
|
||||||
|
|
||||||
|
print('Loading HTML...')
|
||||||
|
page=parse(load(f'https://www.newgrounds.com/audio/listen/{songId}').text,'html.parser')
|
||||||
|
songTitle=page.find('title').text
|
||||||
|
|
||||||
|
print('Creating download link...')
|
||||||
|
dllink=f'http://audio.ngfiles.com/{songId[:3]}000/{songId}_'
|
||||||
|
count=0
|
||||||
|
for char in songTitle:
|
||||||
|
if 97<=ord(char.lower())<=122:
|
||||||
|
dllink+=char
|
||||||
|
count+=1
|
||||||
|
elif char==' ':
|
||||||
|
dllink+='-'
|
||||||
|
count+=1
|
||||||
|
if count==26:
|
||||||
|
break
|
||||||
|
dllink+='.mp3'
|
||||||
|
|
||||||
|
if not access('Downloads',F_OK):
|
||||||
|
mkdir('Downloads')
|
||||||
|
|
||||||
|
print(f'Downloading "{songTitle}"...')
|
||||||
|
with open(f'Downloads/{dllink.split("/")[-1]}','wb') as out:
|
||||||
|
out.write(load(dllink).content)
|
||||||
|
print(f'{songTitle} successfully downloaded.')
|
||||||
33
README.md
Normal file
33
README.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Newgrounds Audio Downloader 
|
||||||
|
|
||||||
|
Well, actually sometimes there's a download button on the audio page, but what to do if direct downloads are not allowed by the creator even though you love this song too much?
|
||||||
|
|
||||||
|
You just use **this**.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- 
|
||||||
|
- `requests` library
|
||||||
|
- `bs4` library
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Just run the code and enter the Newgrounds ID of the song you wanna download. That's all.
|
||||||
|
|
||||||
|
_Example:_
|
||||||
|
|
||||||
|
```
|
||||||
|
$ python .\NGAudioDownloader.py
|
||||||
|
|
||||||
|
Enter song id: 807461
|
||||||
|
Loading HTML...
|
||||||
|
Creating download link...
|
||||||
|
Downloading "Mysterious Planet"...
|
||||||
|
Mysterious Planet successfully downloaded.
|
||||||
|
```
|
||||||
|
|
||||||
|
Your downloads will appear in the `Downloads` folder.
|
||||||
|
|
||||||
|
## 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