Initial commit

This commit is contained in:
Masahiko AMANO 2020-08-23 14:14:21 +03:00
commit 9cc8f2ff1c
4 changed files with 70 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
__pycache__
/Downloads

33
NGAudioDownloader.py Normal file
View 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
View File

@ -0,0 +1,33 @@
# Newgrounds Audio Downloader ![(Python 3+)](https://img.shields.io/badge/Python-3+-blue.svg)
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
- ![(Python 3+)](https://img.shields.io/badge/Python-3+-blue.svg)
- `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