First iteration completed
This commit is contained in:
parent
1ffc77d980
commit
dd9986fef8
5 changed files with 37 additions and 31 deletions
|
@ -49,7 +49,8 @@ func status(c *gin.Context, downloader youtube.Downloader) error {
|
|||
func data(c *gin.Context, id string) error {
|
||||
c.Writer.Header().Set("Content-Disposition", "attachment; filename="+strconv.Quote(tasks[id].Filename))
|
||||
c.Writer.Header().Set("Content-Type", "application/octet-stream")
|
||||
http.ServeFile(c.Writer, c.Request, filepath.Join("data", tasks[id].Filename))
|
||||
log.Println(id, tasks[id])
|
||||
http.ServeFile(c.Writer, c.Request, filepath.Join("data", id+filepath.Ext(tasks[id].Filename)))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -72,8 +73,8 @@ func main() {
|
|||
c.AbortWithStatus(http.StatusInternalServerError)
|
||||
}))
|
||||
|
||||
r.GET("/data/:filename", func(c *gin.Context) {
|
||||
if err := data(c, c.Param("filename")); err != nil {
|
||||
r.GET("/data/:id", func(c *gin.Context) {
|
||||
if err := data(c, c.Param("id")); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -910,12 +910,16 @@ var app = (function () {
|
|||
}
|
||||
}
|
||||
|
||||
const config = {
|
||||
endpoint: "http://yt-dls-backend:8080"
|
||||
};
|
||||
|
||||
/* src/Task.svelte generated by Svelte v3.42.4 */
|
||||
|
||||
const { Error: Error_1 } = globals;
|
||||
const file$2 = "src/Task.svelte";
|
||||
|
||||
// (58:0) {:catch error}
|
||||
// (60:0) {:catch error}
|
||||
function create_catch_block(ctx) {
|
||||
let p;
|
||||
let t_value = /*error*/ ctx[8].message + "";
|
||||
|
@ -926,7 +930,7 @@ var app = (function () {
|
|||
p = element("p");
|
||||
t = text(t_value);
|
||||
set_style(p, "color", "red");
|
||||
add_location(p, file$2, 58, 2, 1631);
|
||||
add_location(p, file$2, 60, 2, 1616);
|
||||
},
|
||||
m: function mount(target, anchor) {
|
||||
insert_dev(target, p, anchor);
|
||||
|
@ -942,14 +946,14 @@ var app = (function () {
|
|||
block,
|
||||
id: create_catch_block.name,
|
||||
type: "catch",
|
||||
source: "(58:0) {:catch error}",
|
||||
source: "(60:0) {:catch error}",
|
||||
ctx
|
||||
});
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
// (46:0) {:then video_info}
|
||||
// (48:0) {:then video_info}
|
||||
function create_then_block(ctx) {
|
||||
let a;
|
||||
let div2;
|
||||
|
@ -989,22 +993,22 @@ var app = (function () {
|
|||
t5 = text(/*url*/ ctx[0]);
|
||||
t6 = space();
|
||||
img = element("img");
|
||||
add_location(h5, file$2, 48, 49, 1240);
|
||||
add_location(h5, file$2, 50, 49, 1225);
|
||||
attr_dev(div0, "class", "pb-2 flex-grow-1 bd-highlight");
|
||||
add_location(div0, file$2, 48, 6, 1197);
|
||||
add_location(small0, file$2, 49, 42, 1316);
|
||||
add_location(div0, file$2, 50, 6, 1182);
|
||||
add_location(small0, file$2, 51, 42, 1301);
|
||||
attr_dev(div1, "class", "pb-2 px-2 bd-highlight");
|
||||
add_location(div1, file$2, 49, 6, 1280);
|
||||
add_location(div1, file$2, 51, 6, 1265);
|
||||
attr_dev(div2, "class", "d-flex bd-highlight");
|
||||
add_location(div2, file$2, 47, 4, 1157);
|
||||
add_location(small1, file$2, 54, 7, 1538);
|
||||
add_location(p, file$2, 54, 4, 1535);
|
||||
add_location(div2, file$2, 49, 4, 1142);
|
||||
add_location(small1, file$2, 56, 7, 1523);
|
||||
add_location(p, file$2, 56, 4, 1520);
|
||||
if (!src_url_equal(img.src, img_src_value = /*video_info*/ ctx[3].Thumbnails[0].URL)) attr_dev(img, "src", img_src_value);
|
||||
add_location(img, file$2, 55, 4, 1567);
|
||||
add_location(img, file$2, 57, 4, 1552);
|
||||
attr_dev(a, "href", /*download_path*/ ctx[2]);
|
||||
attr_dev(a, "class", "list-group-item list-group-item-action");
|
||||
attr_dev(a, "aria-current", "true");
|
||||
add_location(a, file$2, 46, 2, 1061);
|
||||
add_location(a, file$2, 48, 2, 1046);
|
||||
},
|
||||
m: function mount(target, anchor) {
|
||||
insert_dev(target, a, anchor);
|
||||
|
@ -1054,14 +1058,14 @@ var app = (function () {
|
|||
block,
|
||||
id: create_then_block.name,
|
||||
type: "then",
|
||||
source: "(46:0) {:then video_info}",
|
||||
source: "(48:0) {:then video_info}",
|
||||
ctx
|
||||
});
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
// (51:6) {#if status.Status}
|
||||
// (53:6) {#if status.Status}
|
||||
function create_if_block$1(ctx) {
|
||||
let div;
|
||||
let span;
|
||||
|
@ -1075,9 +1079,9 @@ var app = (function () {
|
|||
span = element("span");
|
||||
t = text(t_value);
|
||||
attr_dev(span, "class", span_class_value = /*statusBadge*/ ctx[4][/*status*/ ctx[1].Status].class);
|
||||
add_location(span, file$2, 51, 37, 1414);
|
||||
add_location(span, file$2, 53, 37, 1399);
|
||||
attr_dev(div, "class", "pb-2 px-2 bd-highlight");
|
||||
add_location(div, file$2, 51, 1, 1378);
|
||||
add_location(div, file$2, 53, 1, 1363);
|
||||
},
|
||||
m: function mount(target, anchor) {
|
||||
insert_dev(target, div, anchor);
|
||||
|
@ -1100,14 +1104,14 @@ var app = (function () {
|
|||
block,
|
||||
id: create_if_block$1.name,
|
||||
type: "if",
|
||||
source: "(51:6) {#if status.Status}",
|
||||
source: "(53:6) {#if status.Status}",
|
||||
ctx
|
||||
});
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
// (44:24) <p>waiting...</p> {:then video_info}
|
||||
// (46:24) <p>waiting...</p> {:then video_info}
|
||||
function create_pending_block(ctx) {
|
||||
let p;
|
||||
|
||||
|
@ -1115,7 +1119,7 @@ var app = (function () {
|
|||
c: function create() {
|
||||
p = element("p");
|
||||
p.textContent = "waiting...";
|
||||
add_location(p, file$2, 44, 2, 1022);
|
||||
add_location(p, file$2, 46, 2, 1007);
|
||||
},
|
||||
m: function mount(target, anchor) {
|
||||
insert_dev(target, p, anchor);
|
||||
|
@ -1130,7 +1134,7 @@ var app = (function () {
|
|||
block,
|
||||
id: create_pending_block.name,
|
||||
type: "pending",
|
||||
source: "(44:24) <p>waiting...</p> {:then video_info}",
|
||||
source: "(46:24) <p>waiting...</p> {:then video_info}",
|
||||
ctx
|
||||
});
|
||||
|
||||
|
@ -1218,7 +1222,7 @@ var app = (function () {
|
|||
let download_path = "#";
|
||||
|
||||
async function startDownload() {
|
||||
const res = await fetch(`https://yt-dls-api.andreafazzi.eu/download?url=${url}`);
|
||||
const res = await fetch(`${config.endpoint}/download?url=${url}`);
|
||||
$$invalidate(3, video_info = await res.json());
|
||||
|
||||
if (res.ok) {
|
||||
|
@ -1229,12 +1233,12 @@ var app = (function () {
|
|||
}
|
||||
|
||||
async function getStatus() {
|
||||
const res = await fetch(`https://yt-dls-api.andreafazzi.eu/status?url=${url}`);
|
||||
const res = await fetch(`${config.endpoint}/status?url=${url}`);
|
||||
$$invalidate(1, status = await res.json());
|
||||
|
||||
if (res.ok) {
|
||||
if (status.DownloadPath) {
|
||||
$$invalidate(2, download_path = `https://yt-dls-api.andreafazzi.eu/${status.DownloadPath}`);
|
||||
if (status.Id) {
|
||||
$$invalidate(2, download_path = `${config.endpoint}/data/${status.Id}`);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
@ -1261,6 +1265,7 @@ var app = (function () {
|
|||
};
|
||||
|
||||
$$self.$capture_state = () => ({
|
||||
config,
|
||||
url,
|
||||
video_info,
|
||||
status,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -29,7 +29,7 @@
|
|||
status = await res.json();
|
||||
|
||||
if (res.ok) {
|
||||
if (status.DownloadPath) {
|
||||
if (status.Id) {
|
||||
download_path = `${config.endpoint}/data/${status.Id}`;
|
||||
}
|
||||
return status;
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export const config = {
|
||||
endpoint: "http://localhost:8080"
|
||||
endpoint: "http://yt-dls-backend:8080"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue