Skip to content

Commit

Permalink
make it work again
Browse files Browse the repository at this point in the history
  • Loading branch information
Le-Stagiaire committed Jul 4, 2024
1 parent 95a9ee0 commit 80a651c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
20 changes: 17 additions & 3 deletions half_past_five/half_past_five.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,24 @@ def __call__(self, cls):
cls.__name__ + self.suffix)),)
)
return cls


class BaseHandler(tornado.web.RequestHandler):

def set_default_headers(self):
self.set_header("Access-Control-Allow-Origin", "*")
self.set_header("Access-Control-Allow-Headers", "x-requested-with")
self.set_header('Access-Control-Allow-Methods', ' PUT, DELETE, OPTIONS')

def options(self):
# no body
self.set_status(204)
self.finish()


@url(r'/')
class MainHandler(RequestHandler):
class MainHandler(BaseHandler):

def get(self):
self.render("index.html")

Expand All @@ -58,15 +72,15 @@ def post(self):
download_path = os.path.join(
server.settings['static_path'], 'downloads', '%(title)s.%(ext)s')
out = subprocess.run(
['youtube-dl', url, '-f', '140', '-o', download_path,
['yt-dlp', url, '-f', '140', '-o', download_path,
'--print-json'], stdout=subprocess.PIPE)
out = json.loads(out.stdout.decode('utf-8'))
self.write(out)
self.finish()


@url(r'/crop_and_download')
class CropHandler(RequestHandler):
class CropHandler(BaseHandler):

def post(self):
# Extract start and end from form params
Expand Down
3 changes: 2 additions & 1 deletion static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ function init() {
xhttp.onreadystatechange = () => {
if (xhttp.readyState == 4 && xhttp.status == 200) {
const response = JSON.parse(xhttp.response);
wavesurfer.load("/" + response._filename);
console.log(response._filename);
wavesurfer.load(response._filename.split("..").at(-1));
document.getElementById("loading").className = "hidden";
document.getElementById("video-title").textContent = response.title;
document.getElementById("crop-title").value = `${response.title}_cut`;
Expand Down

0 comments on commit 80a651c

Please # to comment.