commit 100a973f47ce2cc638ec7c2703da103c2ede803e Author: Kumi Date: Fri Jun 2 16:14:47 2023 +0000 Initial version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0cffcb3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.json \ No newline at end of file diff --git a/assets/main.css b/assets/main.css new file mode 100644 index 0000000..e69de29 diff --git a/assets/main.js b/assets/main.js new file mode 100644 index 0000000..48efb6d --- /dev/null +++ b/assets/main.js @@ -0,0 +1,65 @@ +async function getConfig(window) { + await $.getJSON("config.json", function (data) { + window.config = data; + }); +} + +async function authenticate(window) { + var oauth_settings; + + await $.ajax({ + url: window.config.peertube_api + "/oauth-clients/local", + }).done(function (data) { + oauth_settings = data; + }); + + await $.ajax({ + url: window.config.peertube_api + "/users/token", + type: "POST", + data: { + client_id: oauth_settings.client_id, + client_secret: oauth_settings.client_secret, + grant_type: "password", + response_type: "code", + username: window.config.peertube_user, + password: window.config.peertube_password, + }, + }).done(function (data) { + window.config.access_token = data.access_token; + window.config.refresh_token = data.refresh_token; + console.log(data.access_token); + }); +} + +async function getVideos(window) { + await getConfig(window); + await authenticate(window); + + await $.ajax({ + url: + window.config.peertube_api + + "/users/me/videos?sort=-createdAt", + type: "GET", + // Add bearer token to header + beforeSend: function (xhr) { + xhr.setRequestHeader( + "Authorization", + "Bearer " + window.config.access_token + ); + }, + }) + .fail(function (data) { + console.log(data); + }) + .done(function (data) { + data.data.forEach(function (video) { + $(".table").append( + "" + + "" + + "" + + "" + video.name + "" + + "" + ); + }); + }); +} diff --git a/config.dist.json b/config.dist.json new file mode 100644 index 0000000..d5e7279 --- /dev/null +++ b/config.dist.json @@ -0,0 +1,6 @@ +{ + "peertube_api": "https://kumi.tube/api/v1", + "peertube_user": "peertube_user", + "peertube_password": "peertube_password", + "peertube_channel": "peertube_channel" +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..d1e1f22 --- /dev/null +++ b/index.html @@ -0,0 +1,34 @@ + + + + + + Video List + + + + +
+
+
+

Video List

+ + + + + + + + +
Video ThumbnailVideo Title
+
+
+
+ + + + +