Skip to content

Commit

Permalink
First commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
liam-ilan committed Mar 21, 2022
0 parents commit 04099ad
Show file tree
Hide file tree
Showing 31 changed files with 534 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.env
.cache
__pycache__
playlists/*
archive/*
_*
Empty file added README.md
Empty file.
38 changes: 38 additions & 0 deletions get_songs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os
import shutil
import threading
from dotenv import load_dotenv
from pydub import AudioSegment
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
from spotify_dl.spotify import fetch_tracks, parse_spotify_url, validate_spotify_url
from spotify_dl.youtube import download_songs, default_filename

# setup spotify client
load_dotenv()
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials())

# get songs, call callback at end with uuid
def get_songs(request_url, uuid, cb):

if validate_spotify_url(request_url):
print(request_url)
# parse url
request_type, request_id = parse_spotify_url(request_url)

# create new songs folder for new songs
os.mkdir('./playlists/' + uuid)

# get songs and put in ./uuid
request_tracks = fetch_tracks(sp, request_type, request_url)

# download_songs(request_tracks, './' + uuid, 'bestaudio/best', False)
download_songs(request_tracks, './playlists/' + uuid, 'bestaudio/best', False)

# build zip named uuid.zip
shutil.make_archive('./archive/' + uuid, 'zip', './playlists/' + uuid)

# delete songs
shutil.rmtree('./playlists/' + uuid)

return cb(uuid)
34 changes: 34 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import shutil
import os
import uuid
from flask import Flask, request, send_file
from get_songs import get_songs

app = Flask(__name__, static_folder='static', static_url_path='')

# serve static files
@app.route('/')
def homepage():
return app.send_static_file('index.html')

# api - get songs given link
@app.route('/api/v1/getsongs', methods=['POST'])
def get_songs_api():

# callback when download is finished
def cb(file_uuid):

# get file
res = send_file('./archive/' + file_uuid + '.zip')

# delete file
os.remove('./archive/' + file_uuid + '.zip')

# return (will be sent to client)
return res

# returns whatever callback returns, input validated in function
return get_songs(request.json['link'], str(uuid.uuid4()), cb)

# init
app.run(host='0.0.0.0')
83 changes: 83 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
attrs==19.3.0
Automat==0.8.0
blinker==1.4
certifi==2019.11.28
chardet==3.0.4
charset-normalizer==2.0.12
click==8.0.4
cloud-init==21.4
colorama==0.4.3
command-not-found==0.3
commonmark==0.9.1
configobj==5.0.6
constantly==15.1.0
cryptography==2.8
dbus-python==1.2.16
distro==1.4.0
distro-info===0.23ubuntu1
entrypoints==0.3
ffmpeg==1.4
Flask==2.0.3
httplib2==0.14.0
hyperlink==19.0.0
idna==2.8
importlib-metadata==1.5.0
incremental==16.10.1
itsdangerous==2.1.1
Jinja2==3.0.3
jsonpatch==1.22
jsonpointer==2.0
jsonschema==3.2.0
keyring==18.0.1
language-selector==0.1
launchpadlib==1.10.13
lazr.restfulclient==0.14.2
lazr.uri==1.0.3
MarkupSafe==2.1.0
more-itertools==4.2.0
mutagen==1.45.1
netifaces==0.10.4
oauthlib==3.1.0
pexpect==4.6.0
pyasn1==0.4.2
pyasn1-modules==0.2.1
pycryptodomex==3.14.1
pydub==0.25.1
Pygments==2.11.2
PyGObject==3.36.0
PyHamcrest==1.9.0
PyJWT==1.7.1
pymacaroons==0.13.0
PyNaCl==1.3.0
pyOpenSSL==19.0.0
pyrsistent==0.15.5
pyserial==3.4
python-apt==2.0.0+ubuntu0.20.4.7
python-debian===0.1.36ubuntu1
python-dotenv==0.19.2
PyYAML==5.3.1
requests==2.27.1
requests-unixsocket==0.2.0
rich==11.2.0
SecretStorage==2.3.1
sentry-sdk==1.5.6
service-identity==18.1.0
simplejson==3.16.0
six==1.16.0
sos==4.2
spotify-dl==8.1.0
spotipy==2.19.0
ssh-import-id==5.10
systemd-python==234
Twisted==18.9.0
ubuntu-advantage-tools==27.6
ufw==0.36
unattended-upgrades==0.1
urllib3==1.26.8
wadllib==1.3.3
websockets==10.2
Werkzeug==2.0.3
youtube-dl==2021.12.17
yt-dlp==2022.2.4
zipp==1.0.0
zope.interface==4.7.1
99 changes: 99 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
@font-face {
font-family: montserrat;
src: url(../fonts/Montserrat/Montserrat-VariableFont_wght.ttf);
}

@keyframes rotation {
from {
transform: rotate(0deg);
}
to {
transform: rotate(359deg);
}
}

* {
font-family: montserrat;
}

body {
background-color: #F5F5F8;
}

#title {
margin: 30px 30px 10px 30px;
font-size: 40pt;
color: #4D2D52;
}

#subtitle {
margin: 0 30px;
font-size: 15pt;
color: #4D2D52;
font-weight: thin;
}

#container {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
position: absolute;
text-align: center;
width: 100%;
margin: 0;
padding: 0;
}

#link-input {
margin: 5px;
padding: 10px;
width: 50%;
border: 2px solid #4D2D52;
border-radius: 1000px;
}

#download-button {
background-color: #4D2D52;
color: white;
border: 0px;
padding: 10px;
border-radius: 1000px;
margin: 10px;
}

#download-button:hover {
transform: scale(1.05)
}

#loading-icon {
display: inline-block;
animation: rotation 2s infinite linear;
}

#loading {
padding: 10px;
margin: 5px;
display: none;
}

#title-box {
display: inline-block;
}

#links {
margin: 70px 30px 0px 30px;
float: right;
}

.link {
margin-left: 30px;
top: 50pt;
color: #4D2D52;
font-weight: bold;
text-decoration: none;
font-size: 15pt;
}

.link:hover {
color: #F08CAE;
}
Binary file not shown.
Binary file not shown.
93 changes: 93 additions & 0 deletions static/fonts/Montserrat/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2011 The Montserrat Project Authors (https://github.com/JulietaUla/Montserrat)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Loading

0 comments on commit 04099ad

Please sign in to comment.