add delete function, fix -4 ipv4 argument on second download subprocess opening

This commit is contained in:
Xevion
2019-12-24 19:43:23 -06:00
parent 92442de38d
commit f9bf9ba4b8

View File

@@ -49,10 +49,15 @@ class YouTubeAudio(db.Model):
def download(self):
print(f'Downloading MP3 for {self.id}')
subprocess.run(f'youtube-dl -x --restrict-filenames --audio-format mp3 -o ./app/sounds/youtube/%(id)s.%(ext)s {self.id}'.split(' '))
subprocess.run(f'youtube-dl -x -4 --restrict-filenames --audio-format mp3 -o ./app/sounds/youtube/%(id)s.%(ext)s {self.id}'.split(' '))
# os.rename(self.filename, self.getPath())
print(f'Finished moving {self.id} into proper folder')
def delete(self):
os.remove(os.path.join('app', 'sounds', 'youtube', self.filename))
db.session.delete(self)
db.session.commit()
class SoundcloudAudio(db.Model):
id = db.Column(db.Integer, primary_key=True) # hidden API-accessible only ID
url = db.Column(db.String(256))