From 9cc8f2ff1cdd077cda96ca5943ba3ef764b35b1b Mon Sep 17 00:00:00 2001 From: H1K0 Date: Sun, 23 Aug 2020 14:14:21 +0300 Subject: [PATCH] Initial commit --- .gitattributes | 2 ++ .gitignore | 2 ++ NGAudioDownloader.py | 33 +++++++++++++++++++++++++++++++++ README.md | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 NGAudioDownloader.py create mode 100644 README.md diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3500581 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +/Downloads \ No newline at end of file diff --git a/NGAudioDownloader.py b/NGAudioDownloader.py new file mode 100644 index 0000000..60a8cee --- /dev/null +++ b/NGAudioDownloader.py @@ -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.') \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4ad50f5 --- /dev/null +++ b/README.md @@ -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 \ No newline at end of file