diff --git a/Dockerfile b/Dockerfile
index 6dfbff4..3aa93b0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -44,7 +44,7 @@ COPY ./tubearchivist/requirements.txt /requirements.txt
RUN pip install --no-cache-dir -r requirements.txt --src /usr/local/src
# copy config files
-COPY docker_assets/nginx.conf /etc/nginx/conf.d/
+COPY docker_assets/nginx.conf /etc/nginx/sites-available/default
# copy application into container
COPY ./tubearchivist /app
diff --git a/browser_extension/README.md b/browser_extension/README.md
deleted file mode 100644
index 9737e6e..0000000
--- a/browser_extension/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# Tube Archivist Companion
-A browser extension to directly add videos from YouTube to Tube Archivist.
-
-## MVP or better *bearly viable product*
-This is a proof of concept with the following functionality:
-- Add your Tube Archivist connection details in the addon popup
-- Inject a download button into youtube search results page
-- Clicking the button will automatically add the video to the your download queue
-
-## Test this extension
-- Firefox
- - Open `about:debugging#/runtime/this-firefox`
- - Click on *Load Temporary Add-on*
- - Select the *manifest.json* file to load the addon.
-- Chrome / Chromium
- - Open `chrome://extensions/`
- - Toggle *Developer mode* on top right
- - Click on *Load unpacked*
- - Open the folder containing the *manifest.json* file.
-
-## Help needed
-This is only minimally useful in this state. Join us on our Discord and please help us improve that.
-
-## Note:
-- For mysterious reasons sometimes the download buttons will only load when refreshing the YouTube search page and not on first load... Hence: Help needed!
-- For your testing environment only for now: Point the extension to the newest *unstable* build.
diff --git a/browser_extension/extension/background.js b/browser_extension/extension/background.js
deleted file mode 100644
index 9e73291..0000000
--- a/browser_extension/extension/background.js
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-extension background script listening for events
-*/
-
-console.log("running background.js");
-
-let browserType = getBrowser();
-
-
-// boilerplate to dedect browser type api
-function getBrowser() {
- if (typeof chrome !== "undefined") {
- if (typeof browser !== "undefined") {
- console.log("detected firefox");
- return browser;
- } else {
- console.log("detected chrome");
- return chrome;
- }
- } else {
- console.log("failed to dedect browser");
- throw "browser detection error"
- };
-}
-
-
-// send post request to API backend
-async function sendPayload(url, token, payload) {
-
- const rawResponse = await fetch(url, {
- method: "POST",
- headers: {
- "Accept": "application/json",
- "Content-Type": "application/json",
- "Authorization": token,
- "mode": "no-cors"
- },
- body: JSON.stringify(payload)
- });
-
- const content = await rawResponse.json();
- return content;
-}
-
-
-// read access storage and send
-function forwardRequest(payload) {
-
- console.log("running forwardRequest");
-
- function onGot(item) {
- console.log(item.access);
-
- const url = `${item.access.url}:${item.access.port}/api/download/`;
- console.log(`sending to ${url}`);
- const token = `Token ${item.access.apiKey}`;
-
- sendPayload(url, token, payload).then(content => {
- console.log(content);
- })
-
- };
-
- function onError(error) {
- console.local("failed to get access details");
- console.log(`Error: ${error}`);
- };
-
- browserType.storage.local.get("access", function(result) {
- onGot(result)
- });
-
-}
-
-
-// listen for messages
-browserType.runtime.onMessage.addListener(
- function(request, sender, sendResponse) {
- console.log("responding from background.js listener");
- console.log(JSON.stringify(request));
- if (request.download) {
- console.log("found new download task");
- let payload = {
- "data": [
- {
- "youtube_id": request.download["videoId"],
- "status": "pending",
- }
- ]
- }
- forwardRequest(payload);
- };
- }
-);
diff --git a/browser_extension/extension/images/icon.png b/browser_extension/extension/images/icon.png
deleted file mode 100644
index 33c0c5b..0000000
Binary files a/browser_extension/extension/images/icon.png and /dev/null differ
diff --git a/browser_extension/extension/images/icon128.png b/browser_extension/extension/images/icon128.png
deleted file mode 100644
index 2c08551..0000000
Binary files a/browser_extension/extension/images/icon128.png and /dev/null differ
diff --git a/browser_extension/extension/images/icon16.png b/browser_extension/extension/images/icon16.png
deleted file mode 100644
index a18ae31..0000000
Binary files a/browser_extension/extension/images/icon16.png and /dev/null differ
diff --git a/browser_extension/extension/images/logo.svg b/browser_extension/extension/images/logo.svg
deleted file mode 100644
index 3f900d4..0000000
--- a/browser_extension/extension/images/logo.svg
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
-
diff --git a/browser_extension/extension/images/question.svg b/browser_extension/extension/images/question.svg
deleted file mode 100644
index 872deef..0000000
--- a/browser_extension/extension/images/question.svg
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
diff --git a/browser_extension/extension/images/social/discord.svg b/browser_extension/extension/images/social/discord.svg
deleted file mode 100644
index dd07931..0000000
--- a/browser_extension/extension/images/social/discord.svg
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
diff --git a/browser_extension/extension/images/social/github.svg b/browser_extension/extension/images/social/github.svg
deleted file mode 100644
index c693abf..0000000
--- a/browser_extension/extension/images/social/github.svg
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
diff --git a/browser_extension/extension/images/social/reddit.svg b/browser_extension/extension/images/social/reddit.svg
deleted file mode 100644
index e6c615c..0000000
--- a/browser_extension/extension/images/social/reddit.svg
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
diff --git a/browser_extension/extension/index.html b/browser_extension/extension/index.html
deleted file mode 100644
index f8c254a..0000000
--- a/browser_extension/extension/index.html
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
-
- TubeArchivist Companion
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/browser_extension/extension/manifest.json b/browser_extension/extension/manifest.json
deleted file mode 100644
index a260861..0000000
--- a/browser_extension/extension/manifest.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "manifest_version": 2,
- "name": "TubeArchivist Companion",
- "description": "Interact with your selhosted TA server.",
- "version": "0.0.1",
- "icons": {
- "128": "/images/icon128.png"
- },
- "browser_action": {
- "default_icon": "/images/icon.png",
- "default_popup": "index.html"
- },
- "permissions": [
- "storage"
- ],
- "content_scripts": [
- {
- "matches": ["https://www.youtube.com/results*"],
- "js": ["script.js"]
- }
- ],
- "background": {
- "scripts": ["background.js"]
- }
-}
diff --git a/browser_extension/extension/popup.js b/browser_extension/extension/popup.js
deleted file mode 100644
index 84c21da..0000000
--- a/browser_extension/extension/popup.js
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Loaded into popup index.html
-*/
-
-let browserType = getBrowser();
-
-// boilerplate to dedect browser type api
-function getBrowser() {
- if (typeof chrome !== "undefined") {
- if (typeof browser !== "undefined") {
- console.log("detected firefox");
- return browser;
- } else {
- console.log("detected chrome");
- return chrome;
- }
- } else {
- console.log("failed to dedect browser");
- throw "browser detection error"
- };
-}
-
-// store access details
-document.getElementById("save-login").addEventListener("click", function () {
- console.log("save form");
- let toStore = {
- "access": {
- "url": document.getElementById("url").value,
- "port": document.getElementById("port").value,
- "apiKey": document.getElementById("api-key").value
- }
- };
- console.log(toStore);
- browserType.storage.local.set(toStore, function() {
- console.log("Stored connection details: " + JSON.stringify(toStore));
- });
-})
-
-// fill in form
-document.addEventListener("DOMContentLoaded", async () => {
-
- console.log("executing dom loader");
-
- function onGot(item) {
- if (!item.access) {
- console.log("no access details found");
- return
- }
- console.log(item.access);
- document.getElementById("url").value = item.access.url;
- document.getElementById("port").value = item.access.port;
- document.getElementById("api-key").value = item.access.apiKey;
- };
-
- function onError(error) {
- console.log(`Error: ${error}`);
- };
-
- browserType.storage.local.get("access", function(result) {
- onGot(result)
- });
-
-})
diff --git a/browser_extension/extension/script.js b/browser_extension/extension/script.js
deleted file mode 100644
index 803e094..0000000
--- a/browser_extension/extension/script.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-content script running on youtube.com
-*/
-
-console.log("running script.js");
-
-let browserType = getBrowser();
-
-setTimeout(function(){
- console.log("running setimeout")
- linkFinder();
- return false;
-}, 2000);
-
-
-// boilerplate to dedect browser type api
-function getBrowser() {
- if (typeof chrome !== "undefined") {
- if (typeof browser !== "undefined") {
- console.log("detected firefox");
- return browser;
- } else {
- console.log("detected chrome");
- return chrome;
- }
- } else {
- console.log("failed to dedect browser");
- throw "browser detection error"
- };
-}
-
-
-// event handler for download task
-function addToDownload(videoId) {
-
- console.log(`downloading ${videoId}`);
- let payload = {
- "download": {
- "videoId": videoId
- }
- };
-
- browserType.runtime.sendMessage(payload);
-
-}
-
-
-// find relevant links to add a button to
-function linkFinder() {
-
- console.log("running link finder");
-
- var allLinks = document.links;
- for (let i = 0; i < allLinks.length; i++) {
-
- const linkItem = allLinks[i];
- const linkDest = linkItem.getAttribute("href");
-
- if (linkDest.startsWith("/watch?v=") && linkItem.id == "video-title") {
- var dlButton = document.createElement("button");
- dlButton.innerText = "download";
- var videoId = linkDest.split("=")[1];
- dlButton.setAttribute("data-id", videoId);
- dlButton.setAttribute("id", "ta-dl-" + videoId);
- dlButton.onclick = function(event) {
- var videoId = this.getAttribute("data-id");
- addToDownload(videoId);
- };
- linkItem.parentElement.appendChild(dlButton);
- }
- }
-}
diff --git a/deploy.sh b/deploy.sh
index 070332c..0818e7a 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -100,6 +100,33 @@ function validate {
}
+# update latest tag compatible es for set and forget
+function sync_latest_es {
+
+ printf "\nsync new es version:\n"
+ read -r VERSION
+
+ if [[ $(systemctl is-active docker) != 'active' ]]; then
+ echo "starting docker"
+ sudo systemctl start docker
+ fi
+
+ sudo docker image pull docker.elastic.co/elasticsearch/elasticsearch:"$VERSION"
+
+ sudo docker tag \
+ docker.elastic.co/elasticsearch/elasticsearch:"$VERSION" \
+ bbilly1/tubearchivist-es
+
+ sudo docker tag \
+ docker.elastic.co/elasticsearch/elasticsearch:"$VERSION" \
+ bbilly1/tubearchivist-es:"$VERSION"
+
+ sudo docker push bbilly1/tubearchivist-es
+ sudo docker push bbilly1/tubearchivist-es:"$VERSION"
+
+}
+
+
# publish unstable tag to docker
function sync_unstable {
@@ -153,23 +180,23 @@ function sync_docker {
}
-# check package versions in requirements.txt for updates
-python version_check.py
-
-
if [[ $1 == "blackhole" ]]; then
sync_blackhole
elif [[ $1 == "test" ]]; then
sync_test "$2"
elif [[ $1 == "validate" ]]; then
+ # check package versions in requirements.txt for updates
+ python version_check.py
validate "$2"
elif [[ $1 == "docker" ]]; then
sync_docker
sync_unstable
elif [[ $1 == "unstable" ]]; then
sync_unstable
+elif [[ $1 == "es" ]]; then
+ sync_latest_es
else
- echo "valid options are: blackhole | test | validate | docker | unstable"
+ echo "valid options are: blackhole | test | validate | docker | unstable | es"
fi
diff --git a/docker_assets/nginx.conf b/docker_assets/nginx.conf
index 2bf3241..e134a8e 100644
--- a/docker_assets/nginx.conf
+++ b/docker_assets/nginx.conf
@@ -1,30 +1,29 @@
server {
listen 8000;
-
+
location /cache/videos/ {
alias /cache/videos/;
}
-
+
location /cache/channels/ {
alias /cache/channels/;
}
-
+
location /cache/playlists/ {
alias /cache/playlists/;
}
-
+
location /media/ {
alias /youtube/;
-
types {
text/vtt vtt;
}
}
-
+
location / {
include uwsgi_params;
uwsgi_pass localhost:8080;
}
-
+
}
\ No newline at end of file
diff --git a/docker_assets/run.sh b/docker_assets/run.sh
index 747548c..31022c7 100644
--- a/docker_assets/run.sh
+++ b/docker_assets/run.sh
@@ -15,11 +15,11 @@ done
# ugly nginx and uwsgi port overwrite with env vars
if [[ -n "$TA_PORT" ]]; then
- sed -i "s/8000/$TA_PORT/g" /etc/nginx/conf.d/nginx.conf
+ sed -i "s/8000/$TA_PORT/g" /etc/nginx/sites-available/default
fi
if [[ -n "$TA_UWSGI_PORT" ]]; then
- sed -i "s/8080/$TA_UWSGI_PORT/g" /etc/nginx/conf.d/nginx.conf
+ sed -i "s/8080/$TA_UWSGI_PORT/g" /etc/nginx/sites-available/default
sed -i "s/8080/$TA_UWSGI_PORT/g" /app/uwsgi.ini
fi
diff --git a/tubearchivist/api/README.md b/tubearchivist/api/README.md
index 8620e3b..9852208 100644
--- a/tubearchivist/api/README.md
+++ b/tubearchivist/api/README.md
@@ -104,3 +104,16 @@ POST /api/download/
## Download Queue Item View
/api/download/\/
+
+
+## Ping View
+Validate your connection with the API
+GET /api/ping
+
+When valid returns message with user id:
+```json
+{
+ "response": "pong",
+ "user": 1
+}
+```
diff --git a/tubearchivist/api/urls.py b/tubearchivist/api/urls.py
index 9c0ed3e..8c1a5f8 100644
--- a/tubearchivist/api/urls.py
+++ b/tubearchivist/api/urls.py
@@ -6,6 +6,7 @@ from api.views import (
DownloadApiListView,
DownloadApiView,
LoginApiView,
+ PingView,
PlaylistApiView,
VideoApiListView,
VideoApiView,
@@ -14,6 +15,7 @@ from api.views import (
from django.urls import path
urlpatterns = [
+ path("ping/", PingView.as_view(), name="ping"),
path("login/", LoginApiView.as_view(), name="api-login"),
path(
"video/",
diff --git a/tubearchivist/api/views.py b/tubearchivist/api/views.py
index e9608c1..bf391a9 100644
--- a/tubearchivist/api/views.py
+++ b/tubearchivist/api/views.py
@@ -263,6 +263,18 @@ class DownloadApiListView(ApiBaseView):
return Response(data)
+class PingView(ApiBaseView):
+ """resolves to /api/ping/
+ GET: test your connection
+ """
+
+ @staticmethod
+ def get(request):
+ """get pong"""
+ data = {"response": "pong", "user": request.user.id}
+ return Response(data)
+
+
class LoginApiView(ObtainAuthToken):
"""resolves to /api/login/
POST: return token and username after successful login
diff --git a/tubearchivist/requirements.txt b/tubearchivist/requirements.txt
index bb4795f..409ebe5 100644
--- a/tubearchivist/requirements.txt
+++ b/tubearchivist/requirements.txt
@@ -4,7 +4,7 @@ Django==4.0.3
django-cors-headers==3.11.0
djangorestframework==3.13.1
Pillow==9.0.1
-redis==4.2.0
+redis==4.2.1
requests==2.27.1
ryd-client==0.0.3
uWSGI==2.0.20