Initial
@ -1,28 +0,0 @@
|
|||||||
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/python-3/.devcontainer/base.Dockerfile
|
|
||||||
|
|
||||||
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
|
|
||||||
ARG VARIANT="3.10-bullseye"
|
|
||||||
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
|
|
||||||
|
|
||||||
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
|
|
||||||
ARG NODE_VERSION="none"
|
|
||||||
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
|
|
||||||
|
|
||||||
RUN sed -i 's/required/sufficient/g' /etc/pam.d/chsh
|
|
||||||
|
|
||||||
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
|
|
||||||
COPY tubearchivist/requirements.txt /tmp/pip-tmp/
|
|
||||||
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
|
|
||||||
&& rm -rf /tmp/pip-tmp
|
|
||||||
|
|
||||||
# [Optional] Uncomment this section to install additional OS packages.
|
|
||||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
|
||||||
&& apt-get -y install --no-install-recommends fish
|
|
||||||
|
|
||||||
ENV SHELL /usr/bin/fish
|
|
||||||
|
|
||||||
USER vscode
|
|
||||||
RUN fish -c "curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher"
|
|
||||||
|
|
||||||
# [Optional] Uncomment this line to install global node packages.
|
|
||||||
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
|
|
@ -1,64 +0,0 @@
|
|||||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
|
|
||||||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/python-3
|
|
||||||
{
|
|
||||||
"name": "Python 3",
|
|
||||||
"build": {
|
|
||||||
"dockerfile": "Dockerfile",
|
|
||||||
"context": "..",
|
|
||||||
"args": {
|
|
||||||
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
|
|
||||||
// Append -bullseye or -buster to pin to an OS version.
|
|
||||||
// Use -bullseye variants on local on arm64/Apple Silicon.
|
|
||||||
"VARIANT": "3.10-bullseye",
|
|
||||||
// Options
|
|
||||||
"NODE_VERSION": "16"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Set *default* container specific settings.json values on container create.
|
|
||||||
"settings": {
|
|
||||||
"python.defaultInterpreterPath": "/usr/local/bin/python",
|
|
||||||
"python.linting.enabled": true,
|
|
||||||
"python.linting.pylintEnabled": true,
|
|
||||||
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
|
|
||||||
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
|
|
||||||
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
|
|
||||||
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
|
|
||||||
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
|
|
||||||
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
|
|
||||||
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
|
|
||||||
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
|
|
||||||
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
|
|
||||||
"typescript.tsdk": "tubearchivist/www/node_modules/typescript/lib",
|
|
||||||
"terminal.integrated.defaultProfile.linux": "fish"
|
|
||||||
},
|
|
||||||
|
|
||||||
// Add the IDs of extensions you want installed when the container is created.
|
|
||||||
"extensions": [
|
|
||||||
"ms-python.python",
|
|
||||||
"ms-python.vscode-pylance",
|
|
||||||
"esbenp.prettier-vscode",
|
|
||||||
"dbaeumer.vscode-eslint",
|
|
||||||
"eamodio.gitlens",
|
|
||||||
"batisteo.vscode-django",
|
|
||||||
"christian-kohler.path-intellisense",
|
|
||||||
"quicktype.quicktype"
|
|
||||||
],
|
|
||||||
|
|
||||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
||||||
"forwardPorts": [3000, 8000],
|
|
||||||
|
|
||||||
// Use 'postCreateCommand' to run commands after the container is created.
|
|
||||||
"postCreateCommand": "chsh -s /usr/bin/fish && fish -c 'fisher install matchai/spacefish'",
|
|
||||||
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
|
|
||||||
"remoteUser": "vscode",
|
|
||||||
"features": {
|
|
||||||
// "fish": "latest",
|
|
||||||
"github-cli": "latest",
|
|
||||||
"docker-in-docker": {
|
|
||||||
"version": "latest",
|
|
||||||
"moby": true
|
|
||||||
},
|
|
||||||
"git": "os-provided"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +1,8 @@
|
|||||||
# Git
|
/node_modules
|
||||||
.git
|
*.log
|
||||||
.gitignore
|
.DS_Store
|
||||||
|
.env
|
||||||
# Docker
|
/.cache
|
||||||
.docker
|
/public/build
|
||||||
|
/build
|
||||||
# Python
|
Old/
|
||||||
tubearchivist/__pycache__/
|
|
||||||
tubearchivist/*/__pycache__/
|
|
||||||
tubearchivist/*/*/__pycache__/
|
|
||||||
tubearchivist/*/*/*/__pycache__/
|
|
||||||
.env/
|
|
||||||
.venv/
|
|
||||||
venv/
|
|
||||||
|
|
||||||
# Unneeded graphics
|
|
||||||
assets/*
|
|
||||||
|
|
||||||
# Unneeded docs
|
|
||||||
docs/*
|
|
||||||
|
|
||||||
# for local testing only
|
|
||||||
testing.sh
|
|
3
.env.example
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
API_URL=
|
||||||
|
API_KEY=
|
||||||
|
PUBLIC_API_URL=
|
@ -1,8 +0,0 @@
|
|||||||
# https://next-auth.js.org/configuration/options#nextauth_secret Used to encrypt JWT
|
|
||||||
NEXTAUTH_SECRET=
|
|
||||||
|
|
||||||
# https://next-auth.js.org/configuration/options#nextauth_url When deploying to production, set the NEXTAUTH_URL environment variable to the canonical URL of your site.
|
|
||||||
NEXTAUTH_URL=
|
|
||||||
|
|
||||||
# URL of the Tubearchivist server without a trailing /
|
|
||||||
NEXT_PUBLIC_TUBEARCHIVIST_URL=
|
|
20
.eslintrc.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/** @type {import('@types/eslint').Linter.BaseConfig} */
|
||||||
|
module.exports = {
|
||||||
|
extends: [
|
||||||
|
"@remix-run/eslint-config",
|
||||||
|
"@remix-run/eslint-config/node",
|
||||||
|
"@remix-run/eslint-config/jest-testing-library",
|
||||||
|
],
|
||||||
|
env: {
|
||||||
|
"cypress/globals": true,
|
||||||
|
},
|
||||||
|
plugins: ["cypress"],
|
||||||
|
// we're using vitest which has a very similar API to jest
|
||||||
|
// (so the linting plugins work nicely), but it means we have to explicitly
|
||||||
|
// set the jest version.
|
||||||
|
settings: {
|
||||||
|
jest: {
|
||||||
|
version: 28,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "next/core-web-vitals"
|
|
||||||
}
|
|
214
.github/workflows/deploy.yml
vendored
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
name: 🚀 Deploy
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
pull_request: {}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
actions: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: ⬣ ESLint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.11.0
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: ⎔ Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
|
||||||
|
- name: 📥 Download deps
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
with:
|
||||||
|
useLockFile: false
|
||||||
|
|
||||||
|
- name: 🔬 Lint
|
||||||
|
run: npm run lint
|
||||||
|
|
||||||
|
typecheck:
|
||||||
|
name: ʦ TypeScript
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.11.0
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: ⎔ Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
|
||||||
|
- name: 📥 Download deps
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
with:
|
||||||
|
useLockFile: false
|
||||||
|
|
||||||
|
- name: 🔎 Type check
|
||||||
|
run: npm run typecheck --if-present
|
||||||
|
|
||||||
|
vitest:
|
||||||
|
name: ⚡ Vitest
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.11.0
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: ⎔ Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
|
||||||
|
- name: 📥 Download deps
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
with:
|
||||||
|
useLockFile: false
|
||||||
|
|
||||||
|
- name: ⚡ Run vitest
|
||||||
|
run: npm run test -- --coverage
|
||||||
|
|
||||||
|
cypress:
|
||||||
|
name: ⚫️ Cypress
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.11.0
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 🏄 Copy test env vars
|
||||||
|
run: cp .env.example .env
|
||||||
|
|
||||||
|
- name: ⎔ Setup node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16
|
||||||
|
|
||||||
|
- name: 📥 Download deps
|
||||||
|
uses: bahmutov/npm-install@v1
|
||||||
|
with:
|
||||||
|
useLockFile: false
|
||||||
|
|
||||||
|
- name: 🛠 Setup Database
|
||||||
|
run: npx prisma migrate reset --force
|
||||||
|
|
||||||
|
- name: ⚙️ Build
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: 🌳 Cypress run
|
||||||
|
uses: cypress-io/github-action@v4
|
||||||
|
with:
|
||||||
|
start: npm run start:mocks
|
||||||
|
wait-on: "http://localhost:8811"
|
||||||
|
env:
|
||||||
|
PORT: "8811"
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: 🐳 Build
|
||||||
|
# only build/deploy main branch on pushes
|
||||||
|
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.11.0
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 👀 Read app name
|
||||||
|
uses: SebRollen/toml-action@v1.0.0
|
||||||
|
id: app_name
|
||||||
|
with:
|
||||||
|
file: "fly.toml"
|
||||||
|
field: "app"
|
||||||
|
|
||||||
|
- name: 🐳 Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
# Setup cache
|
||||||
|
- name: ⚡️ Cache Docker layers
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: 🔑 Fly Registry Auth
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: registry.fly.io
|
||||||
|
username: x
|
||||||
|
password: ${{ secrets.FLY_API_TOKEN }}
|
||||||
|
|
||||||
|
- name: 🐳 Docker build
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}
|
||||||
|
build-args: |
|
||||||
|
COMMIT_SHA=${{ github.sha }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
|
||||||
|
|
||||||
|
# This ugly bit is necessary if you don't want your cache to grow forever
|
||||||
|
# till it hits GitHub's limit of 5GB.
|
||||||
|
# Temp fix
|
||||||
|
# https://github.com/docker/build-push-action/issues/252
|
||||||
|
# https://github.com/moby/buildkit/issues/1896
|
||||||
|
- name: 🚚 Move cache
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache
|
||||||
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
name: 🚀 Deploy
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [lint, typecheck, vitest, cypress, build]
|
||||||
|
# only build/deploy main branch on pushes
|
||||||
|
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 🛑 Cancel Previous Runs
|
||||||
|
uses: styfle/cancel-workflow-action@0.11.0
|
||||||
|
|
||||||
|
- name: ⬇️ Checkout repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: 👀 Read app name
|
||||||
|
uses: SebRollen/toml-action@v1.0.0
|
||||||
|
id: app_name
|
||||||
|
with:
|
||||||
|
file: "fly.toml"
|
||||||
|
field: "app"
|
||||||
|
|
||||||
|
- name: 🚀 Deploy Staging
|
||||||
|
if: ${{ github.ref == 'refs/heads/dev' }}
|
||||||
|
uses: superfly/flyctl-actions@1.3
|
||||||
|
with:
|
||||||
|
args: "deploy --app ${{ steps.app_name.outputs.value }}-staging --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
|
||||||
|
env:
|
||||||
|
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
||||||
|
|
||||||
|
- name: 🚀 Deploy Production
|
||||||
|
if: ${{ github.ref == 'refs/heads/main' }}
|
||||||
|
uses: superfly/flyctl-actions@1.3
|
||||||
|
with:
|
||||||
|
args: "deploy --image registry.fly.io/${{ steps.app_name.outputs.value }}:${{ github.ref_name }}-${{ github.sha }}"
|
||||||
|
env:
|
||||||
|
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
39
.gitignore
vendored
@ -1,35 +1,14 @@
|
|||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
node_modules
|
||||||
|
|
||||||
# dependencies
|
|
||||||
/node_modules
|
|
||||||
/.pnp
|
|
||||||
.pnp.js
|
|
||||||
|
|
||||||
# testing
|
|
||||||
/coverage
|
|
||||||
|
|
||||||
# next.js
|
|
||||||
/.next/
|
|
||||||
/out/
|
|
||||||
|
|
||||||
# production
|
|
||||||
/build
|
/build
|
||||||
|
/public/build
|
||||||
|
.env
|
||||||
|
|
||||||
# misc
|
/cypress/screenshots
|
||||||
.DS_Store
|
/cypress/videos
|
||||||
*.pem
|
/prisma/data.db
|
||||||
|
/prisma/data.db-journal
|
||||||
|
|
||||||
# debug
|
/app/styles/tailwind.css
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
.pnpm-debug.log*
|
|
||||||
|
|
||||||
# local env files
|
Old/
|
||||||
.env*.local
|
|
||||||
|
|
||||||
# vercel
|
|
||||||
.vercel
|
|
||||||
|
|
||||||
# typescript
|
|
||||||
*.tsbuildinfo
|
|
9
.gitpod.Dockerfile
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM gitpod/workspace-full
|
||||||
|
|
||||||
|
# Install Fly
|
||||||
|
RUN curl -L https://fly.io/install.sh | sh
|
||||||
|
ENV FLYCTL_INSTALL="/home/gitpod/.fly"
|
||||||
|
ENV PATH="$FLYCTL_INSTALL/bin:$PATH"
|
||||||
|
|
||||||
|
# Install GitHub CLI
|
||||||
|
RUN brew install gh
|
48
.gitpod.yml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# https://www.gitpod.io/docs/config-gitpod-file
|
||||||
|
|
||||||
|
image:
|
||||||
|
file: .gitpod.Dockerfile
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- port: 3000
|
||||||
|
onOpen: notify
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Restore .env file
|
||||||
|
command: |
|
||||||
|
if [ -f .env ]; then
|
||||||
|
# If this workspace already has a .env, don't override it
|
||||||
|
# Local changes survive a workspace being opened and closed
|
||||||
|
# but they will not persist between separate workspaces for the same repo
|
||||||
|
|
||||||
|
echo "Found .env in workspace"
|
||||||
|
else
|
||||||
|
# There is no .env
|
||||||
|
if [ ! -n "${ENV}" ]; then
|
||||||
|
# There is no $ENV from a previous workspace
|
||||||
|
# Default to the example .env
|
||||||
|
echo "Setting example .env"
|
||||||
|
|
||||||
|
cp .env.example .env
|
||||||
|
else
|
||||||
|
# After making changes to .env, run this line to persist it to $ENV
|
||||||
|
# eval $(gp env -e ENV="$(base64 .env | tr -d '\n')")
|
||||||
|
#
|
||||||
|
# Environment variables set this way are shared between all your workspaces for this repo
|
||||||
|
# The lines below will read $ENV and print a .env file
|
||||||
|
|
||||||
|
echo "Restoring .env from Gitpod"
|
||||||
|
|
||||||
|
echo "${ENV}" | base64 -d | tee .env > /dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
- init: npm install
|
||||||
|
command: npm run setup && npm run dev
|
||||||
|
|
||||||
|
vscode:
|
||||||
|
extensions:
|
||||||
|
- ms-azuretools.vscode-docker
|
||||||
|
- esbenp.prettier-vscode
|
||||||
|
- dbaeumer.vscode-eslint
|
||||||
|
- bradlc.vscode-tailwindcss
|
1
.husky/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
_
|
|
@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
. "$(dirname "$0")/_/husky.sh"
|
|
||||||
|
|
||||||
npx lint-staged
|
|
7
.prettierignore
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
node_modules
|
||||||
|
|
||||||
|
/build
|
||||||
|
/public/build
|
||||||
|
.env
|
||||||
|
|
||||||
|
/app/styles/tailwind.css
|
10
.prettierrc
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"printWidth": 100,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"semi": true,
|
|
||||||
"singleQuote": false,
|
|
||||||
"trailingComma": "all",
|
|
||||||
"bracketSpacing": true,
|
|
||||||
"arrowParens": "always"
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
## Contributing to Tube Archivist
|
|
||||||
|
|
||||||
Welcome, and thanks for showing interest in improving Tube Archivist!
|
|
||||||
If you haven't already, the best place to start is the README. This will give you an overview on what the project is all about.
|
|
||||||
|
|
||||||
## Report a bug
|
|
||||||
|
|
||||||
If you notice something is not working as expected, check to see if it has been previously reported in the [open issues](https://github.com/tubearchivist/tubearchivist/issues).
|
|
||||||
If it has not yet been disclosed, go ahead and create an issue.
|
|
||||||
If the issue doesn't move forward due to a lack of response, I assume it's solved and will close it after some time to keep the list fresh.
|
|
||||||
|
|
||||||
## Wiki
|
|
||||||
|
|
||||||
The wiki is where all user functions are explained in detail. These pages are mirrored into the **docs** folder of the repo. This allows for pull requests and all other features like regular code. Make any changes there, and I'll sync them with the wiki tab.
|
|
||||||
|
|
||||||
## Development Environment
|
|
||||||
|
|
||||||
I have learned the hard way, that working on a dockerized application outside of docker is very error prone and in general not a good idea. So if you want to test your changes, it's best to run them in a docker testing environment.
|
|
||||||
|
|
||||||
This is my setup I have landed on, YMMV:
|
|
||||||
- Clone the repo, work on it with your favorite code editor in your local filesystem. *testing* branch is the where all the changes are happening, might be unstable and is WIP.
|
|
||||||
- Then I have a VM on KVM hypervisor running standard Ubuntu Server LTS with docker installed. The VM keeps my projects separate and offers convenient snapshot functionality. The VM also offers ways to simulate lowend environments by limiting CPU cores and memory. But you could also just run docker on your host system.
|
|
||||||
- The `Dockerfile` is structured in a way that the actual application code is in the last layer so rebuilding the image with only code changes utilizes the build cache for everything else and will just take a few seconds.
|
|
||||||
- Take a look at the `deploy.sh` file. I have my local DNS resolve `tubearchivist.local` to the IP of the VM for convenience. To deploy the latest changes and rebuild the application to the testing VM run:
|
|
||||||
```bash
|
|
||||||
./deploy.sh test
|
|
||||||
```
|
|
||||||
- The command above will call the docker build command with `--build-arg INSTALL_DEBUG=1` to install additional useful debug tools.
|
|
||||||
- The `test` argument takes another optional argument to build for a specific architecture valid options are: `amd64`, `arm64` and `multi`, default is `amd64`.
|
|
||||||
- This `deploy.sh` file is not meant to be universally usable for every possible environment but could serve as an idea on how to automatically rebuild containers to test changes - customize to your liking.
|
|
||||||
|
|
||||||
## Working with Elasticsearch
|
|
||||||
Additionally to the required services as listed in the example docker-compose file, the **Dev Tools** of [Kibana](https://www.elastic.co/guide/en/kibana/current/docker.html) are invaluable for running and testing Elasticsearch queries.
|
|
||||||
|
|
||||||
If you want to run queries in on the Elasticsearch container directly from your host with for example `curl` or something like *postman*, you might want to **publish** the port 9200 instead of just **exposing** it.
|
|
||||||
|
|
||||||
## Implementing a new feature
|
|
||||||
|
|
||||||
Do you see anything on the roadmap that you would like to take a closer look at but you are not sure, what's the best way to tackle that? Or anything not on there yet you'd like to implement but are not sure how? Open up an issue and we try to find a solution together.
|
|
||||||
|
|
||||||
## Making changes
|
|
||||||
|
|
||||||
To fix a bug or implement a feature, fork the repository and make all changes to the testing branch. When ready, create a pull request.
|
|
||||||
|
|
||||||
## Releases
|
|
||||||
|
|
||||||
There are three different docker tags:
|
|
||||||
- **latest**: As the name implies is the latest multiarch release for regular usage.
|
|
||||||
- **unstable**: Intermediate amd64 builds for quick testing and improved collaboration. Don't mix with a *latest* installation, for your testing environment only. This is untested and WIP and will have breaking changes between commits that might require a reset to resolve.
|
|
||||||
- **semantic versioning**: There will be a handful named version tags that will also have a matching release and tag on github.
|
|
||||||
|
|
||||||
If you want to see what's in your container, checkout the matching release tag. A merge to **master** usually means a *latest* or *unstable* release. If you want to preview changes in your testing environment, pull the *unstable* tag or clone the repository and build the docker container with the Dockerfile from the **testing** branch.
|
|
||||||
|
|
||||||
## Code formatting and linting
|
|
||||||
|
|
||||||
To keep things clean and consistent for everybody, there is a github action setup to lint and check the changes. You can test your code locally first if you want. For example if you made changes in the **download** module, run
|
|
||||||
|
|
||||||
```shell
|
|
||||||
./deploy.sh validate tubearchivist/home/src/download.py
|
|
||||||
```
|
|
||||||
|
|
||||||
to validate your changes. If you omit the path, all the project files will get checked. This is subject to change as the codebase improves.
|
|
88
Dockerfile
@ -1,80 +1,32 @@
|
|||||||
# multi stage to build tube archivist
|
FROM node:16-bullseye-slim as deps
|
||||||
# first stage to build python wheel, copy into final image
|
|
||||||
|
|
||||||
|
WORKDIR /myapp
|
||||||
|
|
||||||
# First stage to build python wheel
|
ADD package.json yarn.lock .npmrc ./
|
||||||
FROM python:3.10.4-slim-bullseye AS builder
|
RUN yarn install
|
||||||
ARG TARGETPLATFORM
|
|
||||||
|
|
||||||
RUN apt-get update
|
# Build the app
|
||||||
RUN apt-get install -y --no-install-recommends build-essential gcc curl
|
FROM node:16-bullseye-slim as build
|
||||||
|
|
||||||
# get newest patched ffmpeg and ffprobe builds for amd64 fall back to repo ffmpeg for arm64
|
WORKDIR /myapp
|
||||||
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ] ; then \
|
|
||||||
curl -s https://api.github.com/repos/yt-dlp/FFmpeg-Builds/releases/latest \
|
|
||||||
| grep browser_download_url \
|
|
||||||
| grep ".*master.*linux64.*tar.xz" \
|
|
||||||
| cut -d '"' -f 4 \
|
|
||||||
| xargs curl -L --output ffmpeg.tar.xz && \
|
|
||||||
tar -xf ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffmpeg" && \
|
|
||||||
tar -xf ffmpeg.tar.xz --strip-components=2 --no-anchored -C /usr/bin/ "ffprobe" && \
|
|
||||||
rm ffmpeg.tar.xz \
|
|
||||||
; elif [ "$TARGETPLATFORM" = "linux/arm64" ] ; then \
|
|
||||||
apt-get -y update && apt-get -y install --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/* \
|
|
||||||
; fi
|
|
||||||
|
|
||||||
# install requirements
|
COPY --from=deps /myapp/node_modules /myapp/node_modules
|
||||||
COPY ./tubearchivist/requirements.txt /requirements.txt
|
|
||||||
RUN pip install --user -r requirements.txt
|
|
||||||
|
|
||||||
# build final image
|
ADD . .
|
||||||
FROM python:3.10.4-slim-bullseye as tubearchivist
|
RUN yarn build
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
# Finally, build the production image with minimal footprint
|
||||||
ARG INSTALL_DEBUG
|
FROM node:16-bullseye-slim
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
ENV PORT="8080"
|
||||||
|
ENV NODE_ENV="production"
|
||||||
|
|
||||||
# copy build requirements
|
WORKDIR /myapp
|
||||||
COPY --from=builder /root/.local /root/.local
|
|
||||||
COPY --from=builder /usr/bin/ffmpeg /usr/bin/ffmpeg
|
|
||||||
COPY --from=builder /usr/bin/ffprobe /usr/bin/ffprobe
|
|
||||||
ENV PATH=/root/.local/bin:$PATH
|
|
||||||
|
|
||||||
# install distro packages needed
|
COPY --from=deps /myapp/node_modules /myapp/node_modules
|
||||||
RUN apt-get clean && apt-get -y update && apt-get -y install --no-install-recommends \
|
|
||||||
nginx \
|
|
||||||
atomicparsley \
|
|
||||||
curl && rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# install debug tools for testing environment
|
COPY --from=build /myapp/build /myapp/build
|
||||||
RUN if [ "$INSTALL_DEBUG" ] ; then \
|
COPY --from=build /myapp/public /myapp/public
|
||||||
apt-get -y update && apt-get -y install --no-install-recommends \
|
COPY --from=build /myapp/package.json /myapp/package.json
|
||||||
vim htop bmon net-tools iputils-ping procps \
|
|
||||||
&& pip install --user ipython \
|
|
||||||
; fi
|
|
||||||
|
|
||||||
# make folders
|
ENTRYPOINT [ "yarn", "start" ]
|
||||||
RUN mkdir /cache
|
|
||||||
RUN mkdir /youtube
|
|
||||||
RUN mkdir /app
|
|
||||||
|
|
||||||
# copy config files
|
|
||||||
COPY docker_assets/nginx.conf /etc/nginx/sites-available/default
|
|
||||||
|
|
||||||
# copy application into container
|
|
||||||
COPY ./tubearchivist /app
|
|
||||||
COPY ./docker_assets/run.sh /app
|
|
||||||
COPY ./docker_assets/uwsgi.ini /app
|
|
||||||
|
|
||||||
# volumes
|
|
||||||
VOLUME /cache
|
|
||||||
VOLUME /youtube
|
|
||||||
|
|
||||||
# start
|
|
||||||
WORKDIR /app
|
|
||||||
EXPOSE 8000
|
|
||||||
|
|
||||||
RUN chmod +x ./run.sh
|
|
||||||
|
|
||||||
CMD ["./run.sh"]
|
|
||||||
|
674
LICENSE
@ -1,674 +0,0 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
|
||||||
|
|
||||||
Preamble
|
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
|
||||||
have the freedom to distribute copies of free software (and charge for
|
|
||||||
them if you wish), that you receive source code or can get it if you
|
|
||||||
want it, that you can change the software or use pieces of it in new
|
|
||||||
free programs, and that you know you can do these things.
|
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
0. Definitions.
|
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
|
||||||
License. Each licensee is addressed as "you". "Licensees" and
|
|
||||||
"recipients" may be individuals or organizations.
|
|
||||||
|
|
||||||
To "modify" a work means to copy from or adapt all or part of the work
|
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
|
||||||
on the Program.
|
|
||||||
|
|
||||||
To "propagate" a work means to do anything with it that, without
|
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
|
||||||
parties to make or receive copies. Mere interaction with a user through
|
|
||||||
a computer network, with no transfer of a copy, is not conveying.
|
|
||||||
|
|
||||||
An interactive user interface displays "Appropriate Legal Notices"
|
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
|
||||||
for making modifications to it. "Object code" means any non-source
|
|
||||||
form of a work.
|
|
||||||
|
|
||||||
A "Standard Interface" means an interface that either is an official
|
|
||||||
standard defined by a recognized standards body, or, in the case of
|
|
||||||
interfaces specified for a particular programming language, one that
|
|
||||||
is widely used among developers working in that language.
|
|
||||||
|
|
||||||
The "System Libraries" of an executable work include anything, other
|
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users
|
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
|
||||||
same work.
|
|
||||||
|
|
||||||
2. Basic Permissions.
|
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
|
||||||
permission to run the unmodified Program. The output from running a
|
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not
|
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
|
||||||
the terms of this License in conveying all material for which you do
|
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
|
||||||
measure under any applicable law fulfilling obligations under article
|
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
|
||||||
measures.
|
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
|
||||||
technological measures.
|
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
|
||||||
non-permissive terms added in accord with section 7 apply to the code;
|
|
||||||
keep intact all notices of the absence of any warranty; and give all
|
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey,
|
|
||||||
and you may offer support or warranty protection for a fee.
|
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
|
||||||
You may convey a work based on the Program, or the modifications to
|
|
||||||
produce it from the Program, in the form of source code under the
|
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
|
||||||
"keep intact all notices".
|
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
|
||||||
works, which are not by their nature extensions of the covered work,
|
|
||||||
and which are not combined with it such as to form a larger program,
|
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
|
||||||
in one of these ways:
|
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
|
||||||
medium customarily used for software interchange, for a price no
|
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
|
||||||
with subsection 6b.
|
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated
|
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
|
||||||
possible use to the public, the best way to achieve this is to make it
|
|
||||||
free software which everyone can redistribute and change under these terms.
|
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest
|
|
||||||
to attach them to the start of each source file to most effectively
|
|
||||||
state the exclusion of warranty; and each file should have at least
|
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
|
||||||
Copyright (C) <year> <name of author>
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
|
||||||
notice like this when it starts in an interactive mode:
|
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
||||||
This is free software, and you are welcome to redistribute it
|
|
||||||
under certain conditions; type `show c' for details.
|
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
|
||||||
<http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
199
README.md
@ -1,51 +1,180 @@
|
|||||||
# Tube Archivist Frontend
|
# Remix Indie Stack
|
||||||
|
|
||||||
This repo is WIP, recreation of [Tube Archivist](https://github.com/tubearchivist/tubearchivist) frontend in NextJS/React.
|
![The Remix Indie Stack](https://repository-images.githubusercontent.com/465928257/a241fa49-bd4d-485a-a2a5-5cb8e4ee0abf)
|
||||||
|
|
||||||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
Learn more about [Remix Stacks](https://remix.run/stacks).
|
||||||
|
|
||||||
## Setup your environment
|
```
|
||||||
Copy *.env.local.example* to *.env.local* and set:
|
npx create-remix@latest --template remix-run/indie-stack
|
||||||
- **NEXTAUTH_SECRET**: Some long random string
|
|
||||||
- **NEXTAUTH_URL**: Your frontend, most likely `http://localhost:3000`
|
|
||||||
- **NEXT_PUBLIC_TUBEARCHIVIST_URL**: Your Tube Archivist backend testing server, e.g. `http://localhost:8000`
|
|
||||||
|
|
||||||
In general: Use the [unstable builds](https://github.com/tubearchivist/tubearchivist/blob/master/CONTRIBUTING.md#releases) from Tube Archivist or build the image yourself from *testing* branch.
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
First, run the development server:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run dev
|
|
||||||
# or
|
|
||||||
yarn dev
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Errors:
|
## What's in the stack
|
||||||
- *next command not found*: Install next with `npm install next`
|
|
||||||
- *Error: Invalid src prop [...] hostname [...] is not configured under images in your `next.config.js`*: Add the *NEXT_PUBLIC_TUBEARCHIVIST_URL* to the list of *domains*.
|
|
||||||
- *CORS errors in console*: Set the environment variable `DISABLE_CORS=True` to the Tube Archivist container to circumvent this protection. NEVER do that on network accessible installation.
|
|
||||||
|
|
||||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
- [Fly app deployment](https://fly.io) with [Docker](https://www.docker.com/)
|
||||||
|
- Production-ready [SQLite Database](https://sqlite.org)
|
||||||
|
- Healthcheck endpoint for [Fly backups region fallbacks](https://fly.io/docs/reference/configuration/#services-http_checks)
|
||||||
|
- [GitHub Actions](https://github.com/features/actions) for deploy on merge to production and staging environments
|
||||||
|
- Email/Password Authentication with [cookie-based sessions](https://remix.run/docs/en/v1/api/remix#createcookiesessionstorage)
|
||||||
|
- Database ORM with [Prisma](https://prisma.io)
|
||||||
|
- Styling with [Tailwind](https://tailwindcss.com/)
|
||||||
|
- End-to-end testing with [Cypress](https://cypress.io)
|
||||||
|
- Local third party request mocking with [MSW](https://mswjs.io)
|
||||||
|
- Unit testing with [Vitest](https://vitest.dev) and [Testing Library](https://testing-library.com)
|
||||||
|
- Code formatting with [Prettier](https://prettier.io)
|
||||||
|
- Linting with [ESLint](https://eslint.org)
|
||||||
|
- Static Types with [TypeScript](https://typescriptlang.org)
|
||||||
|
|
||||||
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
|
Not a fan of bits of the stack? Fork it, change it, and use `npx create-remix --template your/repo`! Make it your own.
|
||||||
|
|
||||||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
|
## Quickstart
|
||||||
|
|
||||||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
|
Click this button to create a [Gitpod](https://gitpod.io) workspace with the project set up and Fly pre-installed
|
||||||
|
|
||||||
## Learn More
|
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/from-referrer/)
|
||||||
|
|
||||||
To learn more about Next.js, take a look at the following resources:
|
## Development
|
||||||
|
|
||||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
- This step only applies if you've opted out of having the CLI install dependencies for you:
|
||||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
||||||
|
|
||||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
```sh
|
||||||
|
npx remix init
|
||||||
|
```
|
||||||
|
|
||||||
## Deploy on Vercel
|
- Initial setup: _If you just generated this project, this step has been done for you._
|
||||||
|
|
||||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
```sh
|
||||||
|
npm run setup
|
||||||
|
```
|
||||||
|
|
||||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
- Start dev server:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
This starts your app in development mode, rebuilding assets on file changes.
|
||||||
|
|
||||||
|
The database seed script creates a new user with some data you can use to get started:
|
||||||
|
|
||||||
|
- Email: `rachel@remix.run`
|
||||||
|
- Password: `racheliscool`
|
||||||
|
|
||||||
|
### Relevant code:
|
||||||
|
|
||||||
|
This is a pretty simple note-taking app, but it's a good example of how you can build a full stack app with Prisma and Remix. The main functionality is creating users, logging in and out, and creating and deleting notes.
|
||||||
|
|
||||||
|
- creating users, and logging in and out [./app/models/user.server.ts](./app/models/user.server.ts)
|
||||||
|
- user sessions, and verifying them [./app/session.server.ts](./app/session.server.ts)
|
||||||
|
- creating, and deleting notes [./app/models/note.server.ts](./app/models/note.server.ts)
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|
||||||
|
This Remix Stack comes with two GitHub Actions that handle automatically deploying your app to production and staging environments.
|
||||||
|
|
||||||
|
Prior to your first deployment, you'll need to do a few things:
|
||||||
|
|
||||||
|
- [Install Fly](https://fly.io/docs/getting-started/installing-flyctl/)
|
||||||
|
|
||||||
|
- Sign up and log in to Fly
|
||||||
|
|
||||||
|
```sh
|
||||||
|
fly auth signup
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note:** If you have more than one Fly account, ensure that you are signed into the same account in the Fly CLI as you are in the browser. In your terminal, run `fly auth whoami` and ensure the email matches the Fly account signed into the browser.
|
||||||
|
|
||||||
|
- Create two apps on Fly, one for staging and one for production:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
fly apps create my-remix-app-f962
|
||||||
|
fly apps create my-remix-app-f962-staging
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note:** Make sure this name matches the `app` set in your `fly.toml` file. Otherwise, you will not be able to deploy.
|
||||||
|
|
||||||
|
- Initialize Git.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git init
|
||||||
|
```
|
||||||
|
|
||||||
|
- Create a new [GitHub Repository](https://repo.new), and then add it as the remote for your project. **Do not push your app yet!**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git remote add origin <ORIGIN_URL>
|
||||||
|
```
|
||||||
|
|
||||||
|
- Add a `FLY_API_TOKEN` to your GitHub repo. To do this, go to your user settings on Fly and create a new [token](https://web.fly.io/user/personal_access_tokens/new), then add it to [your repo secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) with the name `FLY_API_TOKEN`.
|
||||||
|
|
||||||
|
- Add a `SESSION_SECRET` to your fly app secrets, to do this you can run the following commands:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
fly secrets set SESSION_SECRET=$(openssl rand -hex 32) --app my-remix-app-f962
|
||||||
|
fly secrets set SESSION_SECRET=$(openssl rand -hex 32) --app my-remix-app-f962-staging
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't have openssl installed, you can also use [1password](https://1password.com/password-generator/) to generate a random secret, just replace `$(openssl rand -hex 32)` with the generated secret.
|
||||||
|
|
||||||
|
- Create a persistent volume for the sqlite database for both your staging and production environments. Run the following:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
fly volumes create data --size 1 --app my-remix-app-f962
|
||||||
|
fly volumes create data --size 1 --app my-remix-app-f962-staging
|
||||||
|
```
|
||||||
|
|
||||||
|
Now that everything is set up you can commit and push your changes to your repo. Every commit to your `main` branch will trigger a deployment to your production environment, and every commit to your `dev` branch will trigger a deployment to your staging environment.
|
||||||
|
|
||||||
|
### Connecting to your database
|
||||||
|
|
||||||
|
The sqlite database lives at `/data/sqlite.db` in your deployed application. You can connect to the live database by running `fly ssh console -C database-cli`.
|
||||||
|
|
||||||
|
### Getting Help with Deployment
|
||||||
|
|
||||||
|
If you run into any issues deploying to Fly, make sure you've followed all of the steps above and if you have, then post as many details about your deployment (including your app name) to [the Fly support community](https://community.fly.io). They're normally pretty responsive over there and hopefully can help resolve any of your deployment issues and questions.
|
||||||
|
|
||||||
|
## GitHub Actions
|
||||||
|
|
||||||
|
We use GitHub Actions for continuous integration and deployment. Anything that gets into the `main` branch will be deployed to production after running tests/build/etc. Anything in the `dev` branch will be deployed to staging.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
### Cypress
|
||||||
|
|
||||||
|
We use Cypress for our End-to-End tests in this project. You'll find those in the `cypress` directory. As you make changes, add to an existing file or create a new file in the `cypress/e2e` directory to test your changes.
|
||||||
|
|
||||||
|
We use [`@testing-library/cypress`](https://testing-library.com/cypress) for selecting elements on the page semantically.
|
||||||
|
|
||||||
|
To run these tests in development, run `npm run test:e2e:dev` which will start the dev server for the app as well as the Cypress client. Make sure the database is running in docker as described above.
|
||||||
|
|
||||||
|
We have a utility for testing authenticated features without having to go through the login flow:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
cy.login();
|
||||||
|
// you are now logged in as a new user
|
||||||
|
```
|
||||||
|
|
||||||
|
We also have a utility to auto-delete the user at the end of your test. Just make sure to add this in each test file:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
afterEach(() => {
|
||||||
|
cy.cleanupUser();
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
That way, we can keep your local db clean and keep your tests isolated from one another.
|
||||||
|
|
||||||
|
### Vitest
|
||||||
|
|
||||||
|
For lower level tests of utilities and individual components, we use `vitest`. We have DOM-specific assertion helpers via [`@testing-library/jest-dom`](https://testing-library.com/jest-dom).
|
||||||
|
|
||||||
|
### Type Checking
|
||||||
|
|
||||||
|
This project uses TypeScript. It's recommended to get TypeScript set up for your editor to get a really great in-editor experience with type checking and auto-complete. To run type checking across the whole project, run `npm run typecheck`.
|
||||||
|
|
||||||
|
### Linting
|
||||||
|
|
||||||
|
This project uses ESLint for linting. That is configured in `.eslintrc.js`.
|
||||||
|
|
||||||
|
### Formatting
|
||||||
|
|
||||||
|
We use [Prettier](https://prettier.io/) for auto-formatting in this project. It's recommended to install an editor plugin (like the [VSCode Prettier plugin](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)) to get auto-formatting on save. There's also a `npm run format` script you can run to format all files in the project.
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
import Head from "next/head";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Dynamically get the title
|
* TODO: Dynamically get the title
|
||||||
* TODO: NextJS recommended pattern for SEO
|
* TODO: NextJS recommended pattern for SEO
|
||||||
*/
|
*/
|
||||||
export const CustomHead = ({ title }: { title?: string }) => {
|
export const CustomHead = ({ title }: { title?: string }) => {
|
||||||
return (
|
return (
|
||||||
<Head>
|
<head>
|
||||||
<meta charSet="UTF-8" />
|
<meta charSet="UTF-8" />
|
||||||
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
|
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
@ -47,6 +45,6 @@ export const CustomHead = ({ title }: { title?: string }) => {
|
|||||||
{/* {% else %} */}
|
{/* {% else %} */}
|
||||||
{/* <link rel="stylesheet" href="/css/light.css" /> */}
|
{/* <link rel="stylesheet" href="/css/light.css" /> */}
|
||||||
{/* {% endif %} */}
|
{/* {% endif %} */}
|
||||||
</Head>
|
</head>
|
||||||
);
|
);
|
||||||
};
|
};
|
@ -1,7 +1,11 @@
|
|||||||
import { Footer } from "./Footer";
|
import { Footer } from "./Footer";
|
||||||
import { Nav } from "./Nav";
|
import { Nav } from "./Nav";
|
||||||
|
|
||||||
export const Layout = ({ children }) => {
|
type Props = {
|
||||||
|
children: React.ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Layout: React.FC<Props> = ({ children }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div style={{ minHeight: "100vh" }} className="main-content">
|
<div style={{ minHeight: "100vh" }} className="main-content">
|
74
app/components/Nav.tsx
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
import BannerDark from "~/images/banner-tube-archivist-dark.png";
|
||||||
|
import IconSearch from "~/images/icon-search.svg";
|
||||||
|
import IconGear from "~/images/icon-gear.svg";
|
||||||
|
import IconExit from "~/images/icon-exit.svg";
|
||||||
|
import { Link } from "@remix-run/react";
|
||||||
|
|
||||||
|
/** TODO: Fix these nav links */
|
||||||
|
export const Nav = () => {
|
||||||
|
return (
|
||||||
|
<div className="boxed-content">
|
||||||
|
<div className="top-banner">
|
||||||
|
<Link to="/">
|
||||||
|
{/* {% if colors == 'dark */}
|
||||||
|
<img
|
||||||
|
width={700}
|
||||||
|
height={150}
|
||||||
|
src={BannerDark}
|
||||||
|
alt="tube-archivist-banner"
|
||||||
|
/>
|
||||||
|
{/* {% endif %} */}
|
||||||
|
{/* {% if colors == 'light */}
|
||||||
|
{/* <img src="/img/banner-tube-archivist-light.png" alt="tube-archivist-banner"> */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div className="top-nav">
|
||||||
|
<div className="nav-items">
|
||||||
|
<Link to="/">
|
||||||
|
<div className="nav-item">home</div>
|
||||||
|
</Link>
|
||||||
|
<Link to="/channel">
|
||||||
|
<div className="nav-item">channels</div>
|
||||||
|
</Link>
|
||||||
|
<Link to="/playlist">
|
||||||
|
<div className="nav-item">playlists</div>
|
||||||
|
</Link>
|
||||||
|
<Link to="/download">
|
||||||
|
<div className="nav-item">downloads</div>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div className="nav-icons">
|
||||||
|
<Link to="/search">
|
||||||
|
<img
|
||||||
|
width={50}
|
||||||
|
height={40}
|
||||||
|
src={IconSearch}
|
||||||
|
alt="search-icon"
|
||||||
|
title="Search"
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
<Link to="/settings">
|
||||||
|
<img
|
||||||
|
width={50}
|
||||||
|
height={40}
|
||||||
|
src={IconGear}
|
||||||
|
alt="gear-icon"
|
||||||
|
title="Settings"
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
<Link to="/logout" style={{ cursor: "pointer" }}>
|
||||||
|
<img
|
||||||
|
width={50}
|
||||||
|
height={40}
|
||||||
|
className="alert-hover"
|
||||||
|
src={IconExit}
|
||||||
|
alt="exit-icon"
|
||||||
|
title="Logout"
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
179
app/components/VideoList/VideoList.tsx
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import IconPlay from "~/images/icon-play.svg";
|
||||||
|
import type { Videos } from "~/routes/index";
|
||||||
|
import type { Datum } from "~/types/Videos";
|
||||||
|
import VideoPlayer from "../VideoPlayer/VideoPlayer";
|
||||||
|
|
||||||
|
type ViewStyle = "grid grid-3" | "list";
|
||||||
|
|
||||||
|
const VideoList = ({ videos }: { videos: Videos }) => {
|
||||||
|
const [selectedVideoUrl, setSelectedVideoUrl] = useState<Datum>();
|
||||||
|
const [viewStyle, setViewStyle] = useState<ViewStyle>("grid grid-3");
|
||||||
|
|
||||||
|
const handleSelectedVideo = (video: Datum) => {
|
||||||
|
setSelectedVideoUrl(video);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRemoveVideoPlayer = () => {
|
||||||
|
setSelectedVideoUrl(undefined);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSetViewstyle = (selectedViewStyle: ViewStyle) => {
|
||||||
|
setViewStyle(selectedViewStyle);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (videos.length < 1) {
|
||||||
|
return (
|
||||||
|
<div className="boxed-content">
|
||||||
|
<h2>No videos found...</h2>
|
||||||
|
<p>
|
||||||
|
If you've already added a channel or playlist, try going to the{" "}
|
||||||
|
<a href="{% url 'downloads">downloads page</a> to start the scan and download tasks.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<VideoPlayer
|
||||||
|
handleRemoveVideoPlayer={handleRemoveVideoPlayer}
|
||||||
|
selectedVideo={selectedVideoUrl}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="boxed-content">
|
||||||
|
<div className="title-bar">
|
||||||
|
<h1>Recent Videos</h1>
|
||||||
|
</div>
|
||||||
|
<div className="view-controls">
|
||||||
|
<div className="toggle">
|
||||||
|
<span>Hide watched:</span>
|
||||||
|
<div className="toggleBox">
|
||||||
|
<input
|
||||||
|
id="hide_watched"
|
||||||
|
// onClick="toggleCheckbox(this)"
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
{/* {% if not hide_watched %} */}
|
||||||
|
<label htmlFor="" className="ofbtn">
|
||||||
|
Off
|
||||||
|
</label>
|
||||||
|
{/* {% else %} */}
|
||||||
|
<label htmlFor="" className="onbtn">
|
||||||
|
On
|
||||||
|
</label>
|
||||||
|
{/* {% endif %} */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="sort">
|
||||||
|
<div id="hidden-form">
|
||||||
|
<span>Sort by:</span>
|
||||||
|
<select name="sort" id="sort" onChange={() => console.log("onChange sort")}>
|
||||||
|
<option value="published">date published</option>
|
||||||
|
<option value="downloaded">date downloaded</option>
|
||||||
|
<option value="views">views</option>
|
||||||
|
<option value="likes">likes</option>
|
||||||
|
</select>
|
||||||
|
<select
|
||||||
|
name="sord-order"
|
||||||
|
id="sort-order"
|
||||||
|
onChange={() => console.log("onChange sort-order")}
|
||||||
|
>
|
||||||
|
<option value="asc">asc</option>
|
||||||
|
<option value="desc">desc</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="view-icons">
|
||||||
|
<img
|
||||||
|
src="/img/icon-sort.svg"
|
||||||
|
alt="sort-icon"
|
||||||
|
onClick={() => console.log("showForm")}
|
||||||
|
id="animate-icon"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
src="/img/icon-gridview.svg"
|
||||||
|
onClick={() => handleSetViewstyle("grid grid-3")}
|
||||||
|
alt="grid view"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
src="/img/icon-listview.svg"
|
||||||
|
onClick={() => handleSetViewstyle("list")}
|
||||||
|
alt="list view"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={`video-list ${viewStyle}`}>
|
||||||
|
{videos.map((video) => {
|
||||||
|
return (
|
||||||
|
<div key={video.youtube_id} className={`video-item ${viewStyle}`}>
|
||||||
|
<div style={{ cursor: "pointer" }} onClick={() => handleSelectedVideo(video)}>
|
||||||
|
<div className={`video-thumb-wrap ${viewStyle}`}>
|
||||||
|
<div className="video-thumb">
|
||||||
|
<img src={video.resolved_thumb_url} alt="video-thumb" />
|
||||||
|
{/* {% if video.source.player.progress %} */}
|
||||||
|
<div
|
||||||
|
className="video-progress-bar"
|
||||||
|
id={`progress-${video.youtube_id}`}
|
||||||
|
// style={{ width: video.youtube_id. }} // TODO: /video/youtube_id/progress
|
||||||
|
/>
|
||||||
|
{/* {% else %} */}
|
||||||
|
{/* <div
|
||||||
|
className="video-progress-bar"
|
||||||
|
id={`progress-${video.youtube_id}`}
|
||||||
|
style={{ width: "0%" }}
|
||||||
|
/> */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
</div>
|
||||||
|
<div className="video-play">
|
||||||
|
<img width={40} height={40} src={IconPlay} alt="play-icon" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={`video-desc ${viewStyle}`}>
|
||||||
|
<div className="video-desc-player" id={`video-info-${video.youtube_id}`}>
|
||||||
|
{video.player.watched ? (
|
||||||
|
<img
|
||||||
|
src="/img/icon-seen.svg"
|
||||||
|
alt="seen-icon"
|
||||||
|
data-id={video.youtube_id}
|
||||||
|
data-status="watched"
|
||||||
|
// onClick="updateVideoWatchStatus(this)"
|
||||||
|
className="watch-button"
|
||||||
|
title="Mark as unwatched"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<img
|
||||||
|
src="/img/icon-unseen.svg"
|
||||||
|
alt="unseen-icon"
|
||||||
|
data-id={video.youtube_id}
|
||||||
|
data-status="unwatched"
|
||||||
|
// onClick="updateVideoWatchStatus(this)"
|
||||||
|
className="watch-button"
|
||||||
|
title="Mark as watched"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<span>
|
||||||
|
{video.published} | {video.player.duration_str}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href={`/channel/${video.channel.channel_id}`}>
|
||||||
|
<h3>{video.channel.channel_name}</h3>
|
||||||
|
</a>
|
||||||
|
<a className="video-more" href={`/video/${video.youtube_id}`}>
|
||||||
|
<h2>{video.title}</h2>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default VideoList;
|
@ -1,15 +1,12 @@
|
|||||||
import NextImage from "next/image";
|
import { Link } from "@remix-run/react";
|
||||||
import NextLink from "next/link";
|
import IconClose from "~/images/icon-close.svg";
|
||||||
import ReactPlayer from "react-player";
|
import { formatNumbers } from "~/lib/utils";
|
||||||
import IconClose from "../../images/icon-close.svg";
|
|
||||||
import { getTAUrl } from "../../lib/constants";
|
|
||||||
import { formatNumbers } from "../../lib/utils";
|
|
||||||
import { Data } from "../../types/video";
|
|
||||||
|
|
||||||
const TA_BASE_URL = getTAUrl();
|
const API_URL =
|
||||||
|
typeof document !== "undefined" ? window.ENV.API_URL : process.env.API_URL;
|
||||||
|
|
||||||
type VideoPlayerProps = {
|
type VideoPlayerProps = {
|
||||||
selectedVideo: Data;
|
selectedVideo: any;
|
||||||
handleRemoveVideoPlayer?: () => void;
|
handleRemoveVideoPlayer?: () => void;
|
||||||
isHome?: boolean;
|
isHome?: boolean;
|
||||||
showStats?: boolean;
|
showStats?: boolean;
|
||||||
@ -21,25 +18,22 @@ const VideoPlayer = ({
|
|||||||
isHome = true,
|
isHome = true,
|
||||||
showStats = true,
|
showStats = true,
|
||||||
}: VideoPlayerProps) => {
|
}: VideoPlayerProps) => {
|
||||||
if (!selectedVideo) return;
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{selectedVideo && (
|
{selectedVideo && (
|
||||||
<div className="player-wrapper">
|
<div className="player-wrapper">
|
||||||
<div className="video-player">
|
<div className="video-player">
|
||||||
<ReactPlayer
|
<video
|
||||||
controls={true}
|
controls={true}
|
||||||
|
autoPlay={true}
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="100%"
|
||||||
light={false}
|
src={`${API_URL}${selectedVideo?.media_url}`}
|
||||||
playing // TODO: Not currently working
|
|
||||||
playsinline
|
|
||||||
url={`${TA_BASE_URL.client}${selectedVideo?.media_url}`}
|
|
||||||
/>
|
/>
|
||||||
<SponsorBlock />
|
<SponsorBlock />
|
||||||
{showStats ? (
|
{showStats ? (
|
||||||
<div className="player-title boxed-content">
|
<div className="player-title boxed-content">
|
||||||
<NextImage
|
<img
|
||||||
className="close-button"
|
className="close-button"
|
||||||
src={IconClose}
|
src={IconClose}
|
||||||
width={30}
|
width={30}
|
||||||
@ -67,11 +61,9 @@ const VideoPlayer = ({
|
|||||||
</h3>
|
</h3>
|
||||||
{/* ${playlist} */}
|
{/* ${playlist} */}
|
||||||
</div>
|
</div>
|
||||||
<NextLink href={`/video/${selectedVideo.youtube_id}/`}>
|
<Link to={`/video/${selectedVideo.youtube_id}/`}>
|
||||||
<a>
|
<h2 id="video-title">{selectedVideo.title}</h2>
|
||||||
<h2 id="video-title">{selectedVideo.title}</h2>
|
</Link>
|
||||||
</a>
|
|
||||||
</NextLink>
|
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
22
app/entry.client.tsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { RemixBrowser } from "@remix-run/react";
|
||||||
|
import { startTransition, StrictMode } from "react";
|
||||||
|
import { hydrateRoot } from "react-dom/client";
|
||||||
|
|
||||||
|
const hydrate = () => {
|
||||||
|
startTransition(() => {
|
||||||
|
hydrateRoot(
|
||||||
|
document,
|
||||||
|
<StrictMode>
|
||||||
|
<RemixBrowser />
|
||||||
|
</StrictMode>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (window.requestIdleCallback) {
|
||||||
|
window.requestIdleCallback(hydrate);
|
||||||
|
} else {
|
||||||
|
// Safari doesn't support requestIdleCallback
|
||||||
|
// https://caniuse.com/requestidlecallback
|
||||||
|
window.setTimeout(hydrate, 1);
|
||||||
|
}
|
53
app/entry.server.tsx
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import { PassThrough } from "stream";
|
||||||
|
import type { EntryContext } from "@remix-run/node";
|
||||||
|
import { Response } from "@remix-run/node";
|
||||||
|
import { RemixServer } from "@remix-run/react";
|
||||||
|
import isbot from "isbot";
|
||||||
|
import { renderToPipeableStream } from "react-dom/server";
|
||||||
|
|
||||||
|
const ABORT_DELAY = 5000;
|
||||||
|
|
||||||
|
export default function handleRequest(
|
||||||
|
request: Request,
|
||||||
|
responseStatusCode: number,
|
||||||
|
responseHeaders: Headers,
|
||||||
|
remixContext: EntryContext
|
||||||
|
) {
|
||||||
|
const callbackName = isbot(request.headers.get("user-agent"))
|
||||||
|
? "onAllReady"
|
||||||
|
: "onShellReady";
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let didError = false;
|
||||||
|
|
||||||
|
const { pipe, abort } = renderToPipeableStream(
|
||||||
|
<RemixServer context={remixContext} url={request.url} />,
|
||||||
|
{
|
||||||
|
[callbackName]: () => {
|
||||||
|
const body = new PassThrough();
|
||||||
|
|
||||||
|
responseHeaders.set("Content-Type", "text/html");
|
||||||
|
|
||||||
|
resolve(
|
||||||
|
new Response(body, {
|
||||||
|
headers: responseHeaders,
|
||||||
|
status: didError ? 500 : responseStatusCode,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
pipe(body);
|
||||||
|
},
|
||||||
|
onShellError: (err: unknown) => {
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
onError: (error: unknown) => {
|
||||||
|
didError = true;
|
||||||
|
|
||||||
|
console.error(error);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
setTimeout(abort, ABORT_DELAY);
|
||||||
|
});
|
||||||
|
}
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 212 KiB |
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 218 KiB |
3
app/lib/constants.server.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export const API_KEY =
|
||||||
|
process.env.API_KEY || `1954c006f731df60bf4c9f027d6b7076d699d319`;
|
||||||
|
export const API_URL = process.env.API_URL || `https://tube.stiforr.tech`;
|
2
app/lib/constants.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export const API_URL =
|
||||||
|
typeof document !== "undefined" ? window.ENV.API_URL : process.env.API_URL;
|
48
app/lib/getChannels.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import type { Channel } from "~/types/channel";
|
||||||
|
import type { Channels } from "../types/channels";
|
||||||
|
import { API_URL } from "./constants.server";
|
||||||
|
|
||||||
|
export const getChannels = async (token: string): Promise<Channels> => {
|
||||||
|
if (!token) {
|
||||||
|
throw new Error(`Unable to fetch channels, no token provided`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(`${API_URL}/api/channel/`, {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Token ${token}`,
|
||||||
|
mode: "no-cors",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Error getting channel information");
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getChannel = async (
|
||||||
|
token: string,
|
||||||
|
id: string | undefined
|
||||||
|
): Promise<Channel> => {
|
||||||
|
if (!token) {
|
||||||
|
throw new Error(`Unable to fetch channels, no token provided`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
throw new Error(`Unable to fetch channel, no id provided`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(`${API_URL}/api/channel/${id}`, {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Token ${token}`,
|
||||||
|
mode: "no-cors",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Error getting channel information");
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
};
|
86
src/lib/getDownloads.ts → app/lib/getDownloads.ts
Executable file → Normal file
@ -1,22 +1,26 @@
|
|||||||
import { Download, Task, Tasks } from "../types/download";
|
import type { Download, Task, Tasks } from "../types/download";
|
||||||
import { getTAUrl } from "./constants";
|
|
||||||
|
|
||||||
|
export const getDownloads = async (
|
||||||
|
token: string,
|
||||||
const TA_BASE_URL = getTAUrl();
|
filter: boolean,
|
||||||
|
pageNumber: number
|
||||||
export const getDownloads = async (token: string, filter: boolean, pageNumber: number): Promise<Download> => {
|
): Promise<Download> => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error(`Unable to fetch downloads, no token provided.`);
|
throw new Error(`Unable to fetch downloads, no token provided.`);
|
||||||
}
|
}
|
||||||
const response = await fetch(`${TA_BASE_URL.server}/api/download/?filter=${filter ? 'ignore' : 'pending'}&page=${pageNumber}`, {
|
const response = await fetch(
|
||||||
headers: {
|
`${API_URL}/api/download/?filter=${
|
||||||
Accept: "application/json",
|
filter ? "ignore" : "pending"
|
||||||
"Content-Type": "application/json",
|
}&page=${pageNumber}`,
|
||||||
Authorization: `Token ${token}`,
|
{
|
||||||
mode: "no-cors",
|
headers: {
|
||||||
},
|
Accept: "application/json",
|
||||||
});
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Token ${token}`,
|
||||||
|
mode: "no-cors",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response.json();
|
return response.json();
|
||||||
} else {
|
} else {
|
||||||
@ -32,17 +36,22 @@ export const getDownloads = async (token: string, filter: boolean, pageNumber: n
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendDownloads = async (token: string, input: string): Promise<Download> => {
|
export const sendDownloads = async (
|
||||||
|
token: string,
|
||||||
|
input: string
|
||||||
|
): Promise<Download> => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error(`Unable to send downloads, no token provided.`);
|
throw new Error(`Unable to send downloads, no token provided.`);
|
||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
"data": [{
|
data: [
|
||||||
"youtube_id": input,
|
{
|
||||||
"status": "pending"
|
youtube_id: input,
|
||||||
}]
|
status: "pending",
|
||||||
|
},
|
||||||
|
],
|
||||||
};
|
};
|
||||||
const response = await fetch(`${TA_BASE_URL.server}/api/download/`, {
|
const response = await fetch(`${API_URL}/api/download/`, {
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
@ -55,18 +64,22 @@ export const sendDownloads = async (token: string, input: string): Promise<Downl
|
|||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response.json();
|
return response.json();
|
||||||
} else if (response.status == 400) {
|
} else if (response.status == 400) {
|
||||||
throw new Error("Failed to extract links. Please input IDs or URLs for videos, channels, or playlists.");
|
throw new Error(
|
||||||
|
"Failed to extract links. Please input IDs or URLs for videos, channels, or playlists."
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Failed to connect to the API.");
|
throw new Error("Failed to connect to the API.");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendDeleteAllQueuedIgnored = async (token: string, filter: string): Promise<Download> => {
|
export const sendDeleteAllQueuedIgnored = async (
|
||||||
|
token: string,
|
||||||
|
filter: string
|
||||||
|
): Promise<Download> => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error(`Unable to delete downloads, no token provided.`);
|
throw new Error(`Unable to delete downloads, no token provided.`);
|
||||||
}
|
}
|
||||||
const response = await fetch(`${TA_BASE_URL.server}/api/download/?filter=${filter}`, {
|
const response = await fetch(`${API_URL}/api/download/?filter=${filter}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -82,11 +95,14 @@ export const sendDeleteAllQueuedIgnored = async (token: string, filter: string):
|
|||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendDeleteVideoQueuedIgnored = async (token: string, videoId: string): Promise<Download> => {
|
export const sendDeleteVideoQueuedIgnored = async (
|
||||||
|
token: string,
|
||||||
|
videoId: string
|
||||||
|
): Promise<Download> => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error(`Unable to delete downloads, no token provided.`);
|
throw new Error(`Unable to delete downloads, no token provided.`);
|
||||||
}
|
}
|
||||||
const response = await fetch(`${TA_BASE_URL.server}/api/download/${videoId}/`, {
|
const response = await fetch(`${API_URL}/api/download/${videoId}/`, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -102,14 +118,18 @@ export const sendDeleteVideoQueuedIgnored = async (token: string, videoId: strin
|
|||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendMoveVideoQueuedIgnored = async (token: string, videoId: string, status: string): Promise<Download> => {
|
export const sendMoveVideoQueuedIgnored = async (
|
||||||
|
token: string,
|
||||||
|
videoId: string,
|
||||||
|
status: string
|
||||||
|
): Promise<Download> => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error(`Unable to move downloads, no token provided.`);
|
throw new Error(`Unable to move downloads, no token provided.`);
|
||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
"status": status
|
status: status,
|
||||||
};
|
};
|
||||||
const response = await fetch(`${TA_BASE_URL.server}/api/download/${videoId}/`, {
|
const response = await fetch(`${API_URL}/api/download/${videoId}/`, {
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
@ -130,9 +150,9 @@ export const sendTasks = async (token: string, task: Tasks): Promise<Task> => {
|
|||||||
throw new Error(`Unable to start task, no token provided.`);
|
throw new Error(`Unable to start task, no token provided.`);
|
||||||
}
|
}
|
||||||
var data = {
|
var data = {
|
||||||
"run": task
|
run: task,
|
||||||
};
|
};
|
||||||
const response = await fetch(`${TA_BASE_URL.server}/api/task/`, {
|
const response = await fetch(`${API_URL}/api/task/`, {
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
@ -146,4 +166,4 @@ export const sendTasks = async (token: string, task: Tasks): Promise<Task> => {
|
|||||||
throw new Error(`Error running task: ${task}.`);
|
throw new Error(`Error running task: ${task}.`);
|
||||||
}
|
}
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
67
app/lib/getPlaylists.ts
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import type { Playlist } from "~/types/playlist";
|
||||||
|
import type { Playlists } from "~/types/playlists";
|
||||||
|
import type { PlaylistVideos } from "~/types/playlistVideos";
|
||||||
|
import { API_URL } from "./constants.server";
|
||||||
|
|
||||||
|
export const getPlaylists = async (token: string): Promise<Playlists> => {
|
||||||
|
if (!token) {
|
||||||
|
throw new Error(`No token provided when fetching a playlists`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(`${API_URL}/api/playlist/`, {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Token ${token}`,
|
||||||
|
mode: "no-cors",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Error getting playlists information: ${response.statusText}`);
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPlaylist = async (
|
||||||
|
token: string,
|
||||||
|
playlistId: string | undefined
|
||||||
|
): Promise<Playlist> => {
|
||||||
|
if (!token) {
|
||||||
|
throw new Error(`No token provided when fetching a playlist: ${playlistId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(`${API_URL}/api/playlist/${playlistId}`, {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Token ${token}`,
|
||||||
|
mode: "no-cors",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Error getting playlists information: ${response.statusText}`);
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPlaylistVideos = async (
|
||||||
|
token: string,
|
||||||
|
id: string | undefined
|
||||||
|
): Promise<PlaylistVideos> => {
|
||||||
|
if (!token) {
|
||||||
|
throw new Error(`No token provided when fetching playlist videos: ${id}`);
|
||||||
|
}
|
||||||
|
const response = await fetch(`${API_URL}/api/playlist/${id}/video/`, {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/json",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Authorization: `Token ${token}`,
|
||||||
|
mode: "no-cors",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Error getting playlist videos: ${response.statusText}`);
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
};
|
@ -1,14 +1,11 @@
|
|||||||
import { Video } from "../types/video";
|
import type { Datum, Videos } from "~/types/Videos";
|
||||||
import { Videos } from "../types/videos";
|
import { API_URL } from "./constants.server";
|
||||||
import { getTAUrl } from "./constants";
|
|
||||||
|
|
||||||
const TA_BASE_URL = getTAUrl();
|
|
||||||
|
|
||||||
export const getVideos = async (token: string): Promise<Videos> => {
|
export const getVideos = async (token: string): Promise<Videos> => {
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error("Missing API token in request to get videos");
|
throw new Error("Missing API token in request to get videos");
|
||||||
}
|
}
|
||||||
const response = await fetch(`${TA_BASE_URL.server}/api/video/`, {
|
const response = await fetch(`${API_URL}/api/video/`, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -18,20 +15,17 @@ export const getVideos = async (token: string): Promise<Videos> => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("Failed to fetch videos");
|
throw new Error(`Failed to fetch videos: ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.json();
|
return response.json();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getVideo = async (
|
export const getVideo = async (token: string, videoId: string): Promise<Datum> => {
|
||||||
token: string,
|
|
||||||
videoId: string
|
|
||||||
): Promise<Video> => {
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
throw new Error("Missing API token in request to get video");
|
throw new Error("Missing API token in request to get video");
|
||||||
}
|
}
|
||||||
const response = await fetch(`${TA_BASE_URL.server}/api/video/${videoId}`, {
|
const response = await fetch(`${API_URL}/api/video/${videoId}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@ -41,7 +35,7 @@ export const getVideo = async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("Failed to fetch videos");
|
throw new Error(`Failed to fetch videos: ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.json();
|
return response.json();
|
60
app/root.tsx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import type { LinksFunction, LoaderArgs, MetaFunction } from "@remix-run/node";
|
||||||
|
import {
|
||||||
|
Links,
|
||||||
|
LiveReload,
|
||||||
|
Meta,
|
||||||
|
Outlet,
|
||||||
|
Scripts,
|
||||||
|
ScrollRestoration,
|
||||||
|
useLoaderData,
|
||||||
|
} from "@remix-run/react";
|
||||||
|
import { Layout } from "./components/Layout";
|
||||||
|
import styles from "./styles/dark.css";
|
||||||
|
import global from "./styles/globals.css";
|
||||||
|
|
||||||
|
export const links: LinksFunction = () => {
|
||||||
|
return [
|
||||||
|
// { rel: "stylesheet", href: tailwindStylesheetUrl },
|
||||||
|
{ rel: "stylesheet", href: styles },
|
||||||
|
{ rel: "stylesheet", href: global },
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const meta: MetaFunction = () => ({
|
||||||
|
charset: "utf-8",
|
||||||
|
title: "Tubearchivist",
|
||||||
|
viewport: "width=device-width,initial-scale=1",
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function loader({ request }: LoaderArgs) {
|
||||||
|
return {
|
||||||
|
ENV: {
|
||||||
|
API_URL: process.env.API_URL,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
const data = useLoaderData();
|
||||||
|
return (
|
||||||
|
<html lang="en" className="h-full">
|
||||||
|
<head>
|
||||||
|
<Meta />
|
||||||
|
<Links />
|
||||||
|
</head>
|
||||||
|
<body className="h-full">
|
||||||
|
<Layout>
|
||||||
|
<Outlet />
|
||||||
|
</Layout>
|
||||||
|
<script
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: `window.ENV = ${JSON.stringify(data.ENV)}`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<ScrollRestoration />
|
||||||
|
<Scripts />
|
||||||
|
<LiveReload />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
}
|
145
app/routes/channel/$id.tsx
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
import { Link, useLoaderData } from "@remix-run/react";
|
||||||
|
import type { LoaderFunction } from "@remix-run/server-runtime";
|
||||||
|
import { API_KEY, API_URL } from "~/lib/constants.server";
|
||||||
|
import { getChannel } from "~/lib/getChannels";
|
||||||
|
import type { Channel } from "~/types/channel";
|
||||||
|
|
||||||
|
export const loader: LoaderFunction = async ({ params }) => {
|
||||||
|
const id = params.id;
|
||||||
|
const channel = await getChannel(API_KEY, id);
|
||||||
|
return channel;
|
||||||
|
};
|
||||||
|
|
||||||
|
const ChannelPage = () => {
|
||||||
|
const channel = useLoaderData<Channel>();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="boxed-content">
|
||||||
|
<div className="channel-banner">
|
||||||
|
<Link to={`/channel/${channel.data.channel_id}/`}>
|
||||||
|
<img
|
||||||
|
src={`${API_URL}${channel.data.channel_banner_url}`}
|
||||||
|
alt="channel_banner"
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="info-box-item channel-nav">
|
||||||
|
<a href="{% url 'channel_id' channel_info.channel_id %}">
|
||||||
|
<h3>Videos</h3>
|
||||||
|
</a>
|
||||||
|
<a href="{% url 'channel_id_playlist' channel_info.channel_id %}">
|
||||||
|
<h3>Playlists</h3>
|
||||||
|
</a>
|
||||||
|
<a href="{% url 'channel_id_about' channel_info.channel_id %}">
|
||||||
|
<h3>About</h3>
|
||||||
|
</a>
|
||||||
|
{/* {% if has_pending %} */}
|
||||||
|
<a href="{% url 'downloads' %}?channel={{ channel_info.channel_id }}">
|
||||||
|
<h3>Downloads</h3>
|
||||||
|
</a>
|
||||||
|
{/* {% endif %} */}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="notifications"></div>
|
||||||
|
|
||||||
|
<div className="info-box info-box-2">
|
||||||
|
<div className="info-box-item">
|
||||||
|
<div className="round-img">
|
||||||
|
<a href="">
|
||||||
|
<img
|
||||||
|
src={`${API_URL}${channel.data.channel_thumb_url}`}
|
||||||
|
alt="channel thumbnail"
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>
|
||||||
|
<a href="">{channel.data.channel_name}</a>
|
||||||
|
</h3>
|
||||||
|
<p>
|
||||||
|
Subscribers: {channel.data.channel_subs.toLocaleString("en-US")}
|
||||||
|
</p>
|
||||||
|
{channel.data.channel_subscribed ? (
|
||||||
|
<button className="unsubscribe">Unsubscribe</button>
|
||||||
|
) : (
|
||||||
|
<button>Subscribe</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="info-box-item">
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
Total Views:{" "}
|
||||||
|
{channel.data.channel_views.toLocaleString("en-US")}
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
title={`Mark all videos from ${channel.data.channel_name} as watched`}
|
||||||
|
>
|
||||||
|
Mark as watched
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="boxed-content boxed-3">
|
||||||
|
<div className="view-controls">
|
||||||
|
<div className="toggle">
|
||||||
|
<span>Hide Watched videos:</span>
|
||||||
|
<div className="toggleBox">
|
||||||
|
<input type="checkbox" name="hide_watched" id="hide_watched" />
|
||||||
|
<label className="ofbtn" htmlFor="hide_watched">
|
||||||
|
Off
|
||||||
|
</label>
|
||||||
|
<label className="onbtn" htmlFor="hide_watched">
|
||||||
|
On
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="sort">
|
||||||
|
<div id="hidden-form">
|
||||||
|
<span>Sort by:</span>
|
||||||
|
<select name="sort" id="sort">
|
||||||
|
<option value="published">date published</option>
|
||||||
|
<option value="downloaded">date downloaded</option>
|
||||||
|
<option value="views">views</option>
|
||||||
|
<option value="likes">likes</option>
|
||||||
|
</select>
|
||||||
|
<select name="sort-order" id="sort-order">
|
||||||
|
<option value="asc">asc</option>
|
||||||
|
<option value="desc">desc</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="view-icons">
|
||||||
|
<img src="/img/icon-sort.svg" alt="sort icon" />
|
||||||
|
<div className="grid-count">
|
||||||
|
<img src="/img/icon-add.svg" alt="grid plus row" />
|
||||||
|
<img src="/img/icon-substract.svg" alt="grid minus row" />
|
||||||
|
</div>
|
||||||
|
<img src="/img/icon-gridview.svg" alt="grid view" />
|
||||||
|
<img src="/img/icon-listview.svg" alt="list view" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="boxed-content boxed-3">
|
||||||
|
<div className="video-list grid-3">
|
||||||
|
<div className="video-item grid">
|
||||||
|
<a href="">
|
||||||
|
<div className="video-thumb-wrap grid">
|
||||||
|
<div className="video-thumb">
|
||||||
|
{/* <img src="thumb_url" alt="" /> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ChannelPage;
|
181
app/routes/channel/index.tsx
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
import { Link, useLoaderData } from "@remix-run/react";
|
||||||
|
import type { LoaderFunction, MetaFunction } from "@remix-run/server-runtime";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { API_URL } from "~/lib/constants";
|
||||||
|
import { API_KEY } from "~/lib/constants.server";
|
||||||
|
import { getChannels } from "~/lib/getChannels";
|
||||||
|
import type { Channels } from "~/types/channels";
|
||||||
|
import { formatNumbers } from "../../lib/utils";
|
||||||
|
|
||||||
|
export const loader: LoaderFunction = async () => {
|
||||||
|
const channels = await getChannels(API_KEY);
|
||||||
|
|
||||||
|
return channels;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const meta: MetaFunction = () => {
|
||||||
|
return {
|
||||||
|
title: "Channels",
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
type ViewStyle = "grid" | "list";
|
||||||
|
|
||||||
|
const ChannelsPage = () => {
|
||||||
|
const channels = useLoaderData<Channels>();
|
||||||
|
const [viewStyle, setViewStyle] = useState<ViewStyle>("grid");
|
||||||
|
|
||||||
|
const handleSetViewstyle = (selectedViewStyle: ViewStyle) => {
|
||||||
|
setViewStyle(selectedViewStyle);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="boxed-content">
|
||||||
|
<div className="title-split">
|
||||||
|
<div className="title-bar">
|
||||||
|
<h1>Channels</h1>
|
||||||
|
</div>
|
||||||
|
<div className="title-split-form">
|
||||||
|
<img
|
||||||
|
id="animate-icon"
|
||||||
|
onClick={() => console.log("showForm()")}
|
||||||
|
src="/img/icon-add.svg"
|
||||||
|
alt="add-icon"
|
||||||
|
title="Subscribe to Channels"
|
||||||
|
/>
|
||||||
|
<div className="show-form">
|
||||||
|
<form id="hidden-form" action="/channel/" method="post">
|
||||||
|
{/* {% csrf_token %}
|
||||||
|
{{ subscribe_form }} */}
|
||||||
|
<button type="submit">Subscribe</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="view-controls">
|
||||||
|
<div className="toggle">
|
||||||
|
<span>Show subscribed only:</span>
|
||||||
|
<div className="toggleBox">
|
||||||
|
<input
|
||||||
|
id="show_subed_only"
|
||||||
|
onClick={() => console.log("toggleCheckbox(this)")}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
{/* {% if not show_subed_only %} */}
|
||||||
|
<label htmlFor="" className="ofbtn">
|
||||||
|
Off
|
||||||
|
</label>
|
||||||
|
{/* {% else %} */}
|
||||||
|
<label htmlFor="" className="onbtn">
|
||||||
|
On
|
||||||
|
</label>
|
||||||
|
{/* {% endif %} */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="view-icons">
|
||||||
|
<img
|
||||||
|
src="/img/icon-gridview.svg"
|
||||||
|
onClick={() => handleSetViewstyle("grid")}
|
||||||
|
alt="grid view"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
src="/img/icon-listview.svg"
|
||||||
|
onClick={() => handleSetViewstyle("list")}
|
||||||
|
alt="list view"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h2>Total matching channels: {channels?.data?.length} </h2>
|
||||||
|
<div className={`channel-list ${viewStyle}`}>
|
||||||
|
{!channels.data ? (
|
||||||
|
<h2>No channels found...</h2>
|
||||||
|
) : (
|
||||||
|
channels.data?.map((channel) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={channel.channel_id}
|
||||||
|
className={`channel-item ${viewStyle}`}
|
||||||
|
>
|
||||||
|
<div className={`channel-banner ${viewStyle}`}>
|
||||||
|
<Link to={channel.channel_id}>
|
||||||
|
<img
|
||||||
|
src={`${API_URL}${channel.channel_banner_url}`}
|
||||||
|
alt="{{ channel.source.channel_id }}-banner"
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div className={`info-box info-box-2 ${viewStyle}`}>
|
||||||
|
<div className="info-box-item">
|
||||||
|
<div className="round-img">
|
||||||
|
<Link to={channel.channel_id}>
|
||||||
|
<img
|
||||||
|
src={`${API_URL}${channel.channel_thumb_url}`}
|
||||||
|
alt="channel-thumb"
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>
|
||||||
|
<Link to={channel.channel_id}>
|
||||||
|
{channel?.channel_name}
|
||||||
|
</Link>
|
||||||
|
</h3>
|
||||||
|
{/* {% if channel.source.channel_subs >= 1000000 %} */}
|
||||||
|
<p>
|
||||||
|
Subscribers: {formatNumbers(channel?.channel_subs)}
|
||||||
|
</p>
|
||||||
|
{/* {% else %} */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="info-box-item">
|
||||||
|
<div>
|
||||||
|
<p>Last refreshed: {channel?.channel_last_refresh} </p>
|
||||||
|
{/* {% if channel.source.channel_subscribed %} */}
|
||||||
|
<button
|
||||||
|
className="unsubscribe"
|
||||||
|
type="button"
|
||||||
|
id="{{ channel.source.channel_id }}"
|
||||||
|
onClick={() =>
|
||||||
|
console.log(
|
||||||
|
"unsubscribe(this.id) -> toggleSubscribe()"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
title={`${
|
||||||
|
channel?.channel_subscribed
|
||||||
|
? "Unsubscribe from"
|
||||||
|
: "Subscribe to"
|
||||||
|
} ${channel?.channel_name}`}
|
||||||
|
>
|
||||||
|
{channel?.channel_subscribed
|
||||||
|
? "Unsubscribe"
|
||||||
|
: "Subscribe"}
|
||||||
|
</button>
|
||||||
|
{/* {% else %} */}
|
||||||
|
{/* <button
|
||||||
|
type="button"
|
||||||
|
id="{{ channel.source.channel_id }}"
|
||||||
|
onClick={() => console.log("subscribe(this.id)")}
|
||||||
|
title="Subscribe to {{ channel.source.channel_name }}"
|
||||||
|
>
|
||||||
|
Subscribe
|
||||||
|
</button> */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
{/* {% endfor %}
|
||||||
|
{% else %} */}
|
||||||
|
{/* <h2>No channels found...</h2> */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ChannelsPage;
|
525
app/routes/download.tsx
Normal file
@ -0,0 +1,525 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { CustomHead } from "~/components/CustomHead";
|
||||||
|
import { Layout } from "~/components/Layout";
|
||||||
|
import AddIcon from "~/images/icon-add.svg";
|
||||||
|
import DownloadIcon from "~/images/icon-download.svg";
|
||||||
|
import GridViewIcon from "~/images/icon-gridview.svg";
|
||||||
|
import ListViewIcon from "~/images/icon-listview.svg";
|
||||||
|
import RescanIcon from "~/images/icon-rescan.svg";
|
||||||
|
import {
|
||||||
|
sendDeleteAllQueuedIgnored,
|
||||||
|
sendDeleteVideoQueuedIgnored,
|
||||||
|
sendDownloads,
|
||||||
|
sendMoveVideoQueuedIgnored,
|
||||||
|
sendTasks,
|
||||||
|
} from "../lib/getDownloads";
|
||||||
|
import type { Tasks } from "~/types/download";
|
||||||
|
|
||||||
|
type ViewStyle = "grid" | "list";
|
||||||
|
type IgnoredStatus = boolean;
|
||||||
|
type FormHidden = boolean;
|
||||||
|
type ErrorMessage = string;
|
||||||
|
type PageNumber = number;
|
||||||
|
|
||||||
|
const Download = () => {
|
||||||
|
const [ignoredStatus, setIgnoredStatus] = useState<IgnoredStatus>(false);
|
||||||
|
const [pageNumber, setPageNumber] = useState<PageNumber>(1);
|
||||||
|
const [formHidden, setFormHidden] = useState<FormHidden>(true);
|
||||||
|
const [viewStyle, setViewStyle] = useState<ViewStyle>(
|
||||||
|
downloads?.config?.default_view?.downloads
|
||||||
|
);
|
||||||
|
const [errorMessage, setErrorMessage] = useState<ErrorMessage>(null);
|
||||||
|
|
||||||
|
const handleSetViewstyle = (selectedViewStyle: ViewStyle) => {
|
||||||
|
setViewStyle(selectedViewStyle);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSetIgnoredStatus = (selectedIgnoredStatus: IgnoredStatus) => {
|
||||||
|
setIgnoredStatus(selectedIgnoredStatus);
|
||||||
|
refetch();
|
||||||
|
handleSetPageNumber(1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSetFormHidden = (selectedFormHidden: FormHidden) => {
|
||||||
|
setFormHidden(selectedFormHidden);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSetErrorMessage = (selectedErrorMessage: ErrorMessage) => {
|
||||||
|
setErrorMessage(selectedErrorMessage);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSetPageNumber = (selectedPageNumber: PageNumber) => {
|
||||||
|
setPageNumber(selectedPageNumber);
|
||||||
|
};
|
||||||
|
|
||||||
|
const addToDownloadQueue = (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
sendDownloads(session.ta_token.token, event.target.vid_url.value)
|
||||||
|
.then(() => {
|
||||||
|
handleSetErrorMessage(null);
|
||||||
|
handleSetFormHidden(true);
|
||||||
|
})
|
||||||
|
.catch((error) => handleSetErrorMessage(error.message));
|
||||||
|
};
|
||||||
|
const handleMoveVideoQueuedIgnored = (
|
||||||
|
session: string,
|
||||||
|
youtube_id: string,
|
||||||
|
status: string
|
||||||
|
) => {
|
||||||
|
sendMoveVideoQueuedIgnored(session, youtube_id, status)
|
||||||
|
.then(() => {
|
||||||
|
handleSetErrorMessage(null);
|
||||||
|
})
|
||||||
|
.catch((error) => handleSetErrorMessage(error.message));
|
||||||
|
};
|
||||||
|
const handleDeleteVideoQueuedIgnored = (
|
||||||
|
session: string,
|
||||||
|
youtube_id: string
|
||||||
|
) => {
|
||||||
|
sendDeleteVideoQueuedIgnored(session, youtube_id)
|
||||||
|
.then(() => {
|
||||||
|
handleSetErrorMessage(null);
|
||||||
|
})
|
||||||
|
.catch((error) => handleSetErrorMessage(error.message));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDeleteAllQueuedIgnored = (session: string, filter: string) => {
|
||||||
|
sendDeleteAllQueuedIgnored(session, filter)
|
||||||
|
.then(() => {
|
||||||
|
handleSetErrorMessage(null);
|
||||||
|
})
|
||||||
|
.catch((error) => handleSetErrorMessage(error.message));
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSendTask = (session: string, task: Tasks) => {
|
||||||
|
sendTasks(session, task)
|
||||||
|
.then((response) => {
|
||||||
|
if (response.success) {
|
||||||
|
handleSetErrorMessage(null);
|
||||||
|
} else {
|
||||||
|
handleSetErrorMessage(`Error running task: ${response.task}.`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => handleSetErrorMessage(error.message));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<CustomHead title="Downloads" />
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<div className="boxed-content">
|
||||||
|
<div className="title-bar">
|
||||||
|
<h1>Downloads</h1>
|
||||||
|
</div>
|
||||||
|
<div id="notifications">
|
||||||
|
{(error || !downloads?.data) && !isLoading && (
|
||||||
|
<div className="error notification">
|
||||||
|
<h3>API Connection Error</h3>
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{errorMessage && (
|
||||||
|
<div className="error notification">
|
||||||
|
<h3>Failed to add downloads to the queue.</h3>
|
||||||
|
<p>{errorMessage}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{
|
||||||
|
// <div className="info notification">
|
||||||
|
// <h3>Adding new videos to download queue.</h3>
|
||||||
|
// <p>Extracting lists</p>
|
||||||
|
// <p>Progress: 0/0</p>
|
||||||
|
// </div>
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// <div className="info notification">
|
||||||
|
// <h3>Rescanning channels and playlists.</h3>
|
||||||
|
// <p>Looking for new videos.</p>
|
||||||
|
// </div>
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// <div className="info notification">
|
||||||
|
// <h3>Downloading: `VIDEO_TITLE`</h3>
|
||||||
|
// <p>processing</p>
|
||||||
|
// <p>`DOWNLOADED_PERCENTAGE`% of `VIDEO_SIVE``VIDEO_SIZE_UNIT` at `DOWNLOAD_SPEED``DOWNLOAD_SPEED_UNIT` - time left: `DOWNLOAD_TIME_LEFT`</p>
|
||||||
|
// <p>processing</p>
|
||||||
|
// <p>Moving</p>
|
||||||
|
// <p>Completed</p>
|
||||||
|
// </div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div id="downloadControl">
|
||||||
|
{/* Appears when video is downloading */}
|
||||||
|
{/* <div className="dl-control-icons">
|
||||||
|
<NextImage
|
||||||
|
width={30}
|
||||||
|
height={30}
|
||||||
|
src={StopIcon}
|
||||||
|
alt="stop icon"
|
||||||
|
title="Stop Download Queue"
|
||||||
|
id="stop-icon"
|
||||||
|
onClick={() => console.log("stopQueue()")}
|
||||||
|
/>
|
||||||
|
<NextImage
|
||||||
|
width={30}
|
||||||
|
height={30}
|
||||||
|
src={CloseIcon}
|
||||||
|
alt="kill icon"
|
||||||
|
title="Kill Download Queue"
|
||||||
|
id="kill-icon"
|
||||||
|
onClick={() => console.log("killQueue()")}
|
||||||
|
/>
|
||||||
|
</div> */}
|
||||||
|
</div>
|
||||||
|
<div className="info-box info-box-3">
|
||||||
|
<div className="icon-text">
|
||||||
|
<NextImage
|
||||||
|
width={80}
|
||||||
|
height={80}
|
||||||
|
src={RescanIcon}
|
||||||
|
alt="rescan-icon"
|
||||||
|
title="Rescan subscriptions"
|
||||||
|
// className="rotate-img" // Set when rescanning
|
||||||
|
onClick={() =>
|
||||||
|
handleSendTask(session.ta_token.token, "rescan_pending")
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{/* <img id="rescan-icon" onclick="rescanPending()" src="{% static 'img/icon-rescan.svg' %}" alt="rescan-icon"></img> */}
|
||||||
|
<p>Rescan subscriptions</p>
|
||||||
|
</div>
|
||||||
|
<div className="icon-text">
|
||||||
|
<NextImage
|
||||||
|
width={80}
|
||||||
|
height={80}
|
||||||
|
src={DownloadIcon}
|
||||||
|
alt="download-icon"
|
||||||
|
title="Start download"
|
||||||
|
// className="bounce-img" // Set when video is downloading
|
||||||
|
onClick={() =>
|
||||||
|
handleSendTask(session.ta_token.token, "download_pending")
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{/* <img id="download-icon" onclick="dlPending()" src="{% static 'img/icon-download.svg' %}" alt="download-icon"></img> */}
|
||||||
|
<p>Start download</p>
|
||||||
|
</div>
|
||||||
|
<div className="icon-text">
|
||||||
|
<NextImage
|
||||||
|
width={80}
|
||||||
|
height={80}
|
||||||
|
src={AddIcon}
|
||||||
|
alt="add-icon"
|
||||||
|
title="Add to download queue"
|
||||||
|
onClick={() =>
|
||||||
|
formHidden
|
||||||
|
? handleSetFormHidden(false)
|
||||||
|
: handleSetFormHidden(true)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<p>Add to download queue</p>
|
||||||
|
{!formHidden && (
|
||||||
|
<div className="show-form">
|
||||||
|
<form id="hidden-form" onSubmit={addToDownloadQueue}>
|
||||||
|
<textarea
|
||||||
|
name="vid_url"
|
||||||
|
cols={40}
|
||||||
|
rows={4}
|
||||||
|
placeholder="Enter Video Urls or IDs here..."
|
||||||
|
required
|
||||||
|
id="id_vid_url"
|
||||||
|
spellCheck="false"
|
||||||
|
/>
|
||||||
|
<button type="submit">Add to download queue</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="view-controls">
|
||||||
|
<div className="toggle">
|
||||||
|
<span>Show only ignored videos:</span>
|
||||||
|
<div className="toggleBox">
|
||||||
|
<input
|
||||||
|
id="show_ignored_only"
|
||||||
|
onChange={() => handleSetIgnoredStatus(!ignoredStatus)}
|
||||||
|
type="checkbox"
|
||||||
|
checked={ignoredStatus}
|
||||||
|
/>
|
||||||
|
<label htmlFor="" className={ignoredStatus ? "onbtn" : "ofbtn"}>
|
||||||
|
{ignoredStatus ? "On" : "Off"}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="view-icons">
|
||||||
|
<div className="view-icons-margin">
|
||||||
|
<NextImage
|
||||||
|
width={30}
|
||||||
|
height={34}
|
||||||
|
src={GridViewIcon}
|
||||||
|
alt="grid view"
|
||||||
|
title="Switch to grid view"
|
||||||
|
onClick={() => handleSetViewstyle("grid")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/* <img src="{% static 'img/icon-gridview.svg' %}" onclick="changeView(this)" data-origin="downloads" data-value="grid" alt="grid view"> */}
|
||||||
|
<div className="view-icons-margin">
|
||||||
|
<NextImage
|
||||||
|
width={30}
|
||||||
|
height={34}
|
||||||
|
src={ListViewIcon}
|
||||||
|
alt="list view"
|
||||||
|
title="Switch to list view"
|
||||||
|
onClick={() => handleSetViewstyle("list")}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/* <img src="{% static 'img/icon-listview.svg' %}" onclick="changeView(this)" data-origin="downloads" data-value="list" alt="list view"> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{ignoredStatus && (
|
||||||
|
<div className="title-split">
|
||||||
|
<h2>Ignored from download</h2>
|
||||||
|
<button
|
||||||
|
onClick={() =>
|
||||||
|
handleDeleteAllQueuedIgnored(session.ta_token.token, "ignore")
|
||||||
|
}
|
||||||
|
title="Remove all ignored videos."
|
||||||
|
>
|
||||||
|
Remove all ignored
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!ignoredStatus && (
|
||||||
|
<div className="title-split">
|
||||||
|
<h2>Download queue</h2>
|
||||||
|
<button
|
||||||
|
onClick={() =>
|
||||||
|
handleDeleteAllQueuedIgnored(
|
||||||
|
session.ta_token.token,
|
||||||
|
"pending"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
title="Remove all videos from the queue."
|
||||||
|
>
|
||||||
|
Remove all queued
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<h3>
|
||||||
|
Total videos: {downloads?.paginate?.total_hits}{" "}
|
||||||
|
{!downloads && !downloads?.message && !ignoredStatus && (
|
||||||
|
<p>
|
||||||
|
No videos queued for download. Press rescan subscriptions to
|
||||||
|
check if there are any new videos.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</h3>
|
||||||
|
<div className={`dl-list ${viewStyle}`}>
|
||||||
|
{!isLoading &&
|
||||||
|
!error &&
|
||||||
|
!downloads?.message &&
|
||||||
|
downloads?.data?.map((video) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={video?.youtube_id}
|
||||||
|
className={`dl-item ${viewStyle}`}
|
||||||
|
>
|
||||||
|
<div className={`dl-thumb ${viewStyle}`}>
|
||||||
|
<img
|
||||||
|
src={`${TA_BASE_URL.server}${video?.vid_thumb_url}`}
|
||||||
|
alt="video_thumb"
|
||||||
|
></img>
|
||||||
|
{ignoredStatus && <span>ignored</span>}
|
||||||
|
{/* {% if show_ignored_only %} */}
|
||||||
|
{/* <span>ignored</span> */}
|
||||||
|
{!ignoredStatus && <span>queued</span>}
|
||||||
|
{/* {% else %} */}
|
||||||
|
{/* <span>queued</span> */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
</div>
|
||||||
|
<div className={`dl-desc ${viewStyle}`}>
|
||||||
|
<h3>{video?.title}</h3>
|
||||||
|
{video?.channel_indexed && (
|
||||||
|
<a href={`/channel/${video?.channel_id}`}>
|
||||||
|
{video?.channel_name}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
{/* {% if video.source.channel_indexed %} */}
|
||||||
|
{/* <a href="{% url 'channel_id' video.source.channel_id %}">{{ video.source.channel_name }}</a> */}
|
||||||
|
{!video?.channel_indexed && (
|
||||||
|
<span>{video?.channel_name}</span>
|
||||||
|
)}
|
||||||
|
{/* {% else %} */}
|
||||||
|
{/* <span>{{ video.source.channel_name }}</span> */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
<p>
|
||||||
|
Published: {video?.published} | Duration:{" "}
|
||||||
|
{video?.duration} | {video?.youtube_id}
|
||||||
|
</p>
|
||||||
|
{/* <p>Published: {{ video.source.published }} | Duration: {{ video.source.duration }} | {{ video.source.youtube_id }}</p> */}
|
||||||
|
{ignoredStatus && (
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
className="button-padding"
|
||||||
|
title="Move this video to the download queue."
|
||||||
|
onClick={() =>
|
||||||
|
handleMoveVideoQueuedIgnored(
|
||||||
|
session.ta_token.token,
|
||||||
|
video?.youtube_id,
|
||||||
|
"pending"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Add to queue
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="button-padding"
|
||||||
|
title="Remove this video from the ignored list."
|
||||||
|
onClick={() =>
|
||||||
|
handleDeleteVideoQueuedIgnored(
|
||||||
|
session.ta_token.token,
|
||||||
|
video?.youtube_id
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Remove
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{/* {% if show_ignored_only %} */}
|
||||||
|
{/* <button data-id="{{ video.source.youtube_id }}" onclick="forgetIgnore(this)">Forget</button> */}
|
||||||
|
{/* <button data-id="{{ video.source.youtube_id }}" onclick="addSingle(this)">Add to queue</button> */}
|
||||||
|
{!ignoredStatus && (
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
className="button-padding"
|
||||||
|
title="Ignore this video."
|
||||||
|
onClick={() =>
|
||||||
|
handleMoveVideoQueuedIgnored(
|
||||||
|
session.ta_token.token,
|
||||||
|
video?.youtube_id,
|
||||||
|
"ignore"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Ignore
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="button-padding"
|
||||||
|
title="Download this video now."
|
||||||
|
onClick={() => console.log("downloadNow(this)")}
|
||||||
|
>
|
||||||
|
Download now
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="button-padding"
|
||||||
|
title="Remove this video from the queue."
|
||||||
|
onClick={() =>
|
||||||
|
handleDeleteVideoQueuedIgnored(
|
||||||
|
session.ta_token.token,
|
||||||
|
video?.youtube_id
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Remove
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{/* {% else %} */}
|
||||||
|
{/* <button data-id="{{ video.source.youtube_id }}" onclick="toIgnore(this)">Ignore</button> */}
|
||||||
|
{/* <button id="{{ video.source.youtube_id }}" data-id="{{ video.source.youtube_id }}" onclick="downloadNow(this)">Download now</button> */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{/* {% if results %} */}
|
||||||
|
{/* {% for video in results %} */}
|
||||||
|
{/* <div className="dl-item {{ view_style }}" id="dl-{{ video.source.youtube_id }}"> */}
|
||||||
|
{/* <div className="dl-thumb {{ view_style }}"> */}
|
||||||
|
{/* <img src="/cache/{{ video.source.vid_thumb_url }}" alt="video_thumb"> */}
|
||||||
|
{/* {% if show_ignored_only %} */}
|
||||||
|
{/* <span>ignored</span> */}
|
||||||
|
{/* {% else %} */}
|
||||||
|
{/* <span>queued</span> */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
{/* </div> */}
|
||||||
|
{/* <div className="dl-desc {{ view_style }}"> */}
|
||||||
|
{/* <h3>{{ video.source.title }}</h3> */}
|
||||||
|
{/* {% if video.source.channel_indexed %} */}
|
||||||
|
{/* <a href="{% url 'channel_id' video.source.channel_id %}">{{ video.source.channel_name }}</a> */}
|
||||||
|
{/* {% else %} */}
|
||||||
|
{/* <span>{{ video.source.channel_name }}</span> */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
{/* <p>Published: {{ video.source.published }} | Duration: {{ video.source.duration }} | {{ video.source.youtube_id }}</p> */}
|
||||||
|
{/* {% if show_ignored_only %} */}
|
||||||
|
{/* <button data-id="{{ video.source.youtube_id }}" onclick="forgetIgnore(this)">Forget</button> */}
|
||||||
|
{/* <button data-id="{{ video.source.youtube_id }}" onclick="addSingle(this)">Add to queue</button> */}
|
||||||
|
{/* {% else %} */}
|
||||||
|
{/* <button data-id="{{ video.source.youtube_id }}" onclick="toIgnore(this)">Ignore</button> */}
|
||||||
|
{/* <button id="{{ video.source.youtube_id }}" data-id="{{ video.source.youtube_id }}" onclick="downloadNow(this)">Download now</button> */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
{/* </div> */}
|
||||||
|
{/* </div> */}
|
||||||
|
{/* {% endfor %} */}
|
||||||
|
{/* {% endif %} */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="boxed-content">
|
||||||
|
<div className="pagination">
|
||||||
|
{pageNumber != 1 ? (
|
||||||
|
<a
|
||||||
|
className="pagination-item"
|
||||||
|
onClick={() => handleSetPageNumber(1)}
|
||||||
|
>
|
||||||
|
First
|
||||||
|
</a>
|
||||||
|
) : (
|
||||||
|
``
|
||||||
|
)}
|
||||||
|
{downloads?.paginate?.prev_pages &&
|
||||||
|
downloads?.paginate?.prev_pages?.map((page) => {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
key={`${page}`}
|
||||||
|
className="pagination-item"
|
||||||
|
onClick={() => handleSetPageNumber(page)}
|
||||||
|
>
|
||||||
|
{page}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{pageNumber != 1 && <span> < </span>}
|
||||||
|
<span> Page {pageNumber}</span>
|
||||||
|
{downloads?.paginate?.last_page && <span> > </span>}
|
||||||
|
{downloads?.paginate?.next_pages &&
|
||||||
|
downloads?.paginate?.next_pages?.map((page) => {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
key={`${page}`}
|
||||||
|
className="pagination-item"
|
||||||
|
onClick={() => handleSetPageNumber(page)}
|
||||||
|
>
|
||||||
|
{page}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{downloads?.paginate?.last_page && (
|
||||||
|
<a
|
||||||
|
className="pagination-item"
|
||||||
|
onClick={() =>
|
||||||
|
handleSetPageNumber(downloads?.paginate?.last_page)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{" "}
|
||||||
|
Last ({downloads?.paginate?.last_page}){" "}
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* <script type="text/javascript" src="{% static 'progress.js' %}"></script> */}
|
||||||
|
</Layout>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Download;
|
43
app/routes/index.tsx
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { useLoaderData } from "@remix-run/react";
|
||||||
|
import type { ErrorBoundaryComponent, LoaderFunction } from "@remix-run/server-runtime";
|
||||||
|
|
||||||
|
import VideoList from "~/components/VideoList/VideoList";
|
||||||
|
import { API_KEY } from "~/lib/constants.server";
|
||||||
|
import { getVideos } from "~/lib/getVideos";
|
||||||
|
import type { Datum } from "~/types/Videos";
|
||||||
|
|
||||||
|
export const loader: LoaderFunction = async ({ context, request }) => {
|
||||||
|
const { data } = await getVideos(API_KEY);
|
||||||
|
const withVideoThumbs = data.map((d) => ({
|
||||||
|
...d,
|
||||||
|
resolved_thumb_url: `http://localhost:8000${d.vid_thumb_url}`,
|
||||||
|
}));
|
||||||
|
|
||||||
|
return withVideoThumbs;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Videos = Datum[] & {
|
||||||
|
resolved_thumb_url: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Index() {
|
||||||
|
const videos = useLoaderData<Videos>();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main>
|
||||||
|
<VideoList videos={videos} />
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ErrorBoundary: ErrorBoundaryComponent = ({ error }: { error: Error }) => {
|
||||||
|
console.warn(error);
|
||||||
|
return (
|
||||||
|
<div className="boxed-content">
|
||||||
|
<div className="title-bar">
|
||||||
|
<h1>Error: </h1>
|
||||||
|
<p>{error.message}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
191
app/routes/playlist/$id.tsx
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
import { Link, useLoaderData } from "@remix-run/react";
|
||||||
|
import type { LoaderFunction } from "@remix-run/server-runtime";
|
||||||
|
import { API_URL } from "~/lib/constants";
|
||||||
|
import { API_KEY } from "~/lib/constants.server";
|
||||||
|
import { getChannel } from "~/lib/getChannels";
|
||||||
|
import { getPlaylist, getPlaylistVideos } from "~/lib/getPlaylists";
|
||||||
|
import type { Channel } from "~/types/channel";
|
||||||
|
import type { Playlist } from "~/types/playlist";
|
||||||
|
import type { PlaylistVideos } from "~/types/playlistVideos";
|
||||||
|
|
||||||
|
export const loader: LoaderFunction = async ({ params, context, request }) => {
|
||||||
|
const playlist = await getPlaylist(API_KEY, params.id);
|
||||||
|
const channel = await getChannel(API_KEY, playlist.data.playlist_channel_id);
|
||||||
|
const videos = await getPlaylistVideos(API_KEY, params.id);
|
||||||
|
|
||||||
|
const channelThumb = `http://localhost:8000${channel.data.channel_thumb_url}`;
|
||||||
|
return { playlist, channel, channelThumb, videos };
|
||||||
|
};
|
||||||
|
|
||||||
|
export const PlaylistPage = () => {
|
||||||
|
const { playlist, channel, channelThumb, videos } = useLoaderData<{
|
||||||
|
playlist: Playlist;
|
||||||
|
channel: Channel;
|
||||||
|
channelThumb: string;
|
||||||
|
videos: PlaylistVideos;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="boxed-content">
|
||||||
|
<div className="title-bar">
|
||||||
|
<h1>{playlist.data.playlist_name}</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="info-box info-box-3">
|
||||||
|
<div className="info-box-item">
|
||||||
|
<div className="round-img">
|
||||||
|
<Link to={`/channel/${channel.data.channel_id}`}>
|
||||||
|
<img src={channelThumb} alt="channel thumb" />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>
|
||||||
|
<Link to={`/channel/${channel.data.channel_id}`}>{channel.data.channel_name}</Link>
|
||||||
|
</h3>
|
||||||
|
<span>Subscribers: {channel.data.channel_subs.toLocaleString("en-US")}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="info-box-item">
|
||||||
|
<div>
|
||||||
|
<p>Last refreshed: {playlist.data.playlist_last_refresh}</p>
|
||||||
|
<p>
|
||||||
|
Playlist:{" "}
|
||||||
|
{playlist.data.playlist_subscribed ? (
|
||||||
|
<button className="unsubscribe">Unsubscribe</button>
|
||||||
|
) : (
|
||||||
|
<button>Subscribe</button>
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Youtube:{" "}
|
||||||
|
<a
|
||||||
|
href={`https://www.youtube.com/playlist?list=${playlist.data.playlist_id}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>
|
||||||
|
Active
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
<button id="delete-item">Delete Playlist</button>
|
||||||
|
<div className="delete-confirm" id="delete-button">
|
||||||
|
<span>Delete {playlist.data.playlist_name}</span>
|
||||||
|
<button data-action="metadata" data-id="{{ playlist_info.playlist_id }}">
|
||||||
|
Delete metadata
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
data-action="all"
|
||||||
|
className="danger-button"
|
||||||
|
data-id="{{ playlist_info.playlist_id }}"
|
||||||
|
>
|
||||||
|
Delete all
|
||||||
|
</button>
|
||||||
|
<br />
|
||||||
|
<button>Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="info-box-item">
|
||||||
|
<div>
|
||||||
|
<p>Total Videos archived: {playlist.data.playlist_entries.length}</p>
|
||||||
|
<p>
|
||||||
|
Watched:{" "}
|
||||||
|
<button title={`Mark all videos from ${playlist.data.playlist_name} as watched`}>
|
||||||
|
Mark as watched
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="description-box">
|
||||||
|
<p id="text-expand" className="description-text">
|
||||||
|
{playlist.data.playlist_description}
|
||||||
|
</p>
|
||||||
|
<button id="text-expand-button">Show more</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="boxed-content grid-3 grid">
|
||||||
|
<div className="view-controls">
|
||||||
|
<div className="toggle">
|
||||||
|
<span>Hide watched videos:</span>
|
||||||
|
<div className="toggleBox">
|
||||||
|
<input type="checkbox" name="" id="hide_watched" />
|
||||||
|
<label htmlFor="hide_watched" className="ofbtn">
|
||||||
|
Off
|
||||||
|
</label>
|
||||||
|
<label htmlFor="hide_watched" className="onbtn">
|
||||||
|
On
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="view-icons">
|
||||||
|
<div className="grid-count">
|
||||||
|
<img src="/img/icon-add.svg" alt="grid plus row" />
|
||||||
|
<img src="/img/icon-substract.svg" alt="grid minus row" />
|
||||||
|
</div>
|
||||||
|
<img src="/img/icon-gridview.svg" alt="grid view" />
|
||||||
|
<img src="/img/icon-listview.svg" alt="list view" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="player" className="player-wrapper"></div>
|
||||||
|
|
||||||
|
<div className="boxed-content boxed-d">
|
||||||
|
<div className="video-list grid-3 grid">
|
||||||
|
{videos.data.map((video) => (
|
||||||
|
<div key={video.youtube_id} className="video-item grid">
|
||||||
|
<a href="#player">
|
||||||
|
<div className="video-thumb-wrap grid">
|
||||||
|
<div className="video-thumb">
|
||||||
|
<img src={`${API_URL}${video.vid_thumb_url}`} alt="video thumbnail" />
|
||||||
|
<div
|
||||||
|
className="video-progress-bar"
|
||||||
|
style={{ width: video.player.duration }}
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
<div className="video-play">
|
||||||
|
<img src="/img/icon-play.svg" alt="play button" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<div className="video-desc grid">
|
||||||
|
<div className="video-desc-player">
|
||||||
|
{video.player.watched ? (
|
||||||
|
<img src="/img/icon-seen.svg" alt="seen indicator" className="watch-button" />
|
||||||
|
) : (
|
||||||
|
<img src="/img/icon-unseen.svg" alt="seen indicator" className="watch-button" />
|
||||||
|
)}
|
||||||
|
<span>
|
||||||
|
{video.published} | {video.player.duration_str}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="/video/:id" className="video-more">
|
||||||
|
<h2>{video.title}</h2>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ErrorBoundary = ({ error }: { error: Error }) => {
|
||||||
|
console.log(error);
|
||||||
|
return (
|
||||||
|
<div className="boxed-content">
|
||||||
|
<div className="title-bar">
|
||||||
|
<h1>Error: </h1>
|
||||||
|
<p>{error.message}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PlaylistPage;
|
@ -1,59 +1,24 @@
|
|||||||
import { GetServerSideProps } from "next";
|
|
||||||
import NextImage from "next/image";
|
|
||||||
import { getSession, useSession } from "next-auth/react";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { dehydrate, QueryClient, useQuery } from "react-query";
|
import { Link, useLoaderData } from "@remix-run/react";
|
||||||
import { CustomHead } from "../components/CustomHead";
|
import IconAdd from "~/images/icon-add.svg";
|
||||||
import { Layout } from "../components/Layout";
|
import IconGridView from "~/images/icon-gridview.svg";
|
||||||
import { getTAUrl } from "../lib/constants";
|
import IconListView from "~/images/icon-listview.svg";
|
||||||
import { getPlaylists } from "../lib/getPlaylists";
|
import type { LoaderFunction } from "@remix-run/server-runtime";
|
||||||
import IconAdd from "../images/icon-add.svg";
|
import { getPlaylists } from "~/lib/getPlaylists";
|
||||||
import IconListView from "../images/icon-listview.svg";
|
import { API_KEY } from "~/lib/constants.server";
|
||||||
import IconGridView from "../images/icon-gridview.svg";
|
import type { Playlists } from "~/types/playlists";
|
||||||
|
import { API_URL } from "~/lib/constants";
|
||||||
|
|
||||||
|
export const loader: LoaderFunction = async () => {
|
||||||
|
const playlists = await getPlaylists(API_KEY);
|
||||||
|
|
||||||
|
return playlists;
|
||||||
|
};
|
||||||
|
|
||||||
type ViewStyle = "grid" | "list";
|
type ViewStyle = "grid" | "list";
|
||||||
|
|
||||||
const TA_BASE_URL = getTAUrl();
|
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
|
||||||
const queryClient = new QueryClient();
|
|
||||||
const session = await getSession(context);
|
|
||||||
|
|
||||||
if (!session) {
|
|
||||||
return {
|
|
||||||
redirect: {
|
|
||||||
destination: "/auth/login",
|
|
||||||
permanent: false,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
await queryClient.prefetchQuery(["playlists", session.ta_token.token], () =>
|
|
||||||
getPlaylists(session.ta_token.token)
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
dehydratedState: dehydrate(queryClient),
|
|
||||||
session,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const Playlist = () => {
|
const Playlist = () => {
|
||||||
const { data: session } = useSession();
|
const playlists = useLoaderData<Playlists>();
|
||||||
const {
|
|
||||||
data: { data: playlists },
|
|
||||||
error,
|
|
||||||
isLoading,
|
|
||||||
} = useQuery(
|
|
||||||
["playlists", session.ta_token.token],
|
|
||||||
() => getPlaylists(session.ta_token.token),
|
|
||||||
{
|
|
||||||
enabled: !!session.ta_token.token,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const [viewStyle, setViewStyle] = useState<ViewStyle>("grid");
|
const [viewStyle, setViewStyle] = useState<ViewStyle>("grid");
|
||||||
|
|
||||||
const handleSetViewstyle = (selectedViewStyle: ViewStyle) => {
|
const handleSetViewstyle = (selectedViewStyle: ViewStyle) => {
|
||||||
@ -61,21 +26,19 @@ const Playlist = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<>
|
||||||
<CustomHead title="Playlist" />
|
|
||||||
|
|
||||||
<div className="boxed-content">
|
<div className="boxed-content">
|
||||||
<div className="title-split">
|
<div className="title-split">
|
||||||
<div className="title-bar">
|
<div className="title-bar">
|
||||||
<h1>Playlists</h1>
|
<h1>Playlists</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="title-split-form">
|
<div className="title-split-form">
|
||||||
<NextImage
|
<img
|
||||||
id="animate-icon"
|
id="animate-icon"
|
||||||
// onClick="showForm()"
|
// onClick="showForm()"
|
||||||
src={IconAdd}
|
src={IconAdd}
|
||||||
width={45}
|
width={35}
|
||||||
height={40}
|
height={30}
|
||||||
alt="add-icon"
|
alt="add-icon"
|
||||||
title="Subscribe to Playlists"
|
title="Subscribe to Playlists"
|
||||||
/>
|
/>
|
||||||
@ -97,28 +60,27 @@ const Playlist = () => {
|
|||||||
id="show_subed_only"
|
id="show_subed_only"
|
||||||
// onClick="toggleCheckbox(this)"
|
// onClick="toggleCheckbox(this)"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked
|
|
||||||
/>
|
/>
|
||||||
{/* {% if not show_subed_only %} */}
|
{/* {% if not show_subed_only %} */}
|
||||||
<label htmlFor="" className="ofbtn">
|
<label htmlFor="show_subed_only" className="ofbtn">
|
||||||
Off
|
Off
|
||||||
</label>
|
</label>
|
||||||
{/* {% else %} */}
|
{/* {% else %} */}
|
||||||
<label htmlFor="" className="onbtn">
|
<label htmlFor="show_subed_only" className="onbtn">
|
||||||
On
|
On
|
||||||
</label>
|
</label>
|
||||||
{/* {% endif %} */}
|
{/* {% endif %} */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="view-icons">
|
<div className="view-icons">
|
||||||
<NextImage
|
<img
|
||||||
src={IconGridView}
|
src={IconGridView}
|
||||||
width={35}
|
width={35}
|
||||||
height={30}
|
height={30}
|
||||||
onClick={() => handleSetViewstyle("grid")}
|
onClick={() => handleSetViewstyle("grid")}
|
||||||
alt="grid view"
|
alt="grid view"
|
||||||
/>
|
/>
|
||||||
<NextImage
|
<img
|
||||||
src={IconListView}
|
src={IconListView}
|
||||||
width={35}
|
width={35}
|
||||||
height={30}
|
height={30}
|
||||||
@ -130,22 +92,22 @@ const Playlist = () => {
|
|||||||
<div className={`playlist-list ${viewStyle}`}>
|
<div className={`playlist-list ${viewStyle}`}>
|
||||||
{/* {% if results %}
|
{/* {% if results %}
|
||||||
{% for playlist in results %} */}
|
{% for playlist in results %} */}
|
||||||
{!isLoading && !playlists ? (
|
{!playlists ? (
|
||||||
<h2>No playlists found...</h2>
|
<h2>No playlists found...</h2>
|
||||||
) : (
|
) : (
|
||||||
playlists?.map((playlist) => {
|
playlists.data.map((playlist) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={playlist.playlist_id}
|
key={playlist.playlist_id}
|
||||||
className={`playlist-item ${viewStyle}`}
|
className={`playlist-item ${viewStyle}`}
|
||||||
>
|
>
|
||||||
<div className="playlist-thumbnail">
|
<div className="playlist-thumbnail">
|
||||||
<a href="{% url 'playlist_id' playlist.source.playlist_id %}">
|
<Link to={playlist.playlist_id}>
|
||||||
<img
|
<img
|
||||||
src={`${TA_BASE_URL.client}/${playlist.playlist_thumbnail}`}
|
src={`${API_URL}/${playlist.playlist_thumbnail}`}
|
||||||
alt={`${playlist.playlist_id}-thumbnail`}
|
alt={`${playlist.playlist_id}-thumbnail`}
|
||||||
/>
|
/>
|
||||||
</a>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div className={`playlist-desc ${viewStyle}`}>
|
<div className={`playlist-desc ${viewStyle}`}>
|
||||||
<a href="{% url 'channel_id' playlist.source.playlist_channel_id %}">
|
<a href="{% url 'channel_id' playlist.source.playlist_channel_id %}">
|
||||||
@ -155,26 +117,27 @@ const Playlist = () => {
|
|||||||
<h2> {playlist.playlist_name} </h2>
|
<h2> {playlist.playlist_name} </h2>
|
||||||
</a>
|
</a>
|
||||||
<p>Last refreshed: {playlist.playlist_last_refresh} </p>
|
<p>Last refreshed: {playlist.playlist_last_refresh} </p>
|
||||||
{/* {% if playlist.source.playlist_subscribed %} */}
|
|
||||||
<button
|
{playlist.playlist_subscribed ? (
|
||||||
className="unsubscribe"
|
<button
|
||||||
type="button"
|
className="unsubscribe"
|
||||||
id="{{ playlist.source.playlist_id }}"
|
type="button"
|
||||||
// onClick="unsubscribe(this.id)"
|
id="{{ playlist.source.playlist_id }}"
|
||||||
title="Unsubscribe from {{ playlist.source.playlist_name }}"
|
// onClick="unsubscribe(this.id)"
|
||||||
>
|
title="Unsubscribe from {{ playlist.source.playlist_name }}"
|
||||||
Unsubscribe
|
>
|
||||||
</button>
|
Unsubscribe
|
||||||
{/* {% else %} */}
|
</button>
|
||||||
<button
|
) : (
|
||||||
type="button"
|
<button
|
||||||
id="{{ playlist.source.playlist_id }}"
|
type="button"
|
||||||
// onClick="subscribe(this.id)"
|
id="{{ playlist.source.playlist_id }}"
|
||||||
title="Subscribe to {{ playlist.source.playlist_name }}"
|
// onClick="subscribe(this.id)"
|
||||||
>
|
title="Subscribe to {{ playlist.source.playlist_name }}"
|
||||||
Subscribe
|
>
|
||||||
</button>
|
Subscribe
|
||||||
{/* {% endif %} */}
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -182,7 +145,7 @@ const Playlist = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
@ -1,55 +1,10 @@
|
|||||||
import { GetServerSideProps, NextPage } from "next";
|
import { CustomHead } from "~/components/CustomHead";
|
||||||
import NextImage from "next/image";
|
import { Layout } from "~/components/Layout";
|
||||||
import { getSession, useSession } from "next-auth/react";
|
import { getVideo } from "~/lib/getVideos";
|
||||||
import { useRouter } from "next/router";
|
import VideoPlayer from "~/components/VideoPlayer/VideoPlayer";
|
||||||
import { dehydrate, QueryClient, useQuery } from "react-query";
|
|
||||||
import { CustomHead } from "../../components/CustomHead";
|
|
||||||
import { Layout } from "../../components/Layout";
|
|
||||||
import { getTAUrl } from "../../lib/constants";
|
|
||||||
import { getVideo } from "../../lib/getVideos";
|
|
||||||
import VideoPlayer from "../../components/VideoPlayer/VideoPlayer";
|
|
||||||
|
|
||||||
const TA_BASE_URL = getTAUrl();
|
const Video = () => {
|
||||||
|
const data = { data: [] };
|
||||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
|
||||||
const queryClient = new QueryClient();
|
|
||||||
const session = await getSession(context);
|
|
||||||
const videoId = context.query.videoId;
|
|
||||||
|
|
||||||
if (!session) {
|
|
||||||
return {
|
|
||||||
redirect: {
|
|
||||||
destination: "/auth/login",
|
|
||||||
permanent: false,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
await queryClient.prefetchQuery(["video", videoId], () =>
|
|
||||||
getVideo(session.ta_token.token, videoId as string)
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
dehydratedState: dehydrate(queryClient),
|
|
||||||
session,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const Video: NextPage = () => {
|
|
||||||
const router = useRouter();
|
|
||||||
const { videoId } = router.query;
|
|
||||||
const { data: session } = useSession();
|
|
||||||
const { data, error, isLoading } = useQuery(
|
|
||||||
["video", session.ta_token.token],
|
|
||||||
() => getVideo(session.ta_token.token, videoId as string),
|
|
||||||
{
|
|
||||||
enabled: !!session?.ta_token?.token,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isLoading) return <h1>Loading...</h1>;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
@ -67,8 +22,8 @@ const Video: NextPage = () => {
|
|||||||
<div className="info-box-item">
|
<div className="info-box-item">
|
||||||
<div className="round-img">
|
<div className="round-img">
|
||||||
<a href="{% url 'channel_id' video.channel.channel_id %}">
|
<a href="{% url 'channel_id' video.channel.channel_id %}">
|
||||||
<NextImage
|
<img
|
||||||
src={`${TA_BASE_URL.client}/cache/channels/${data.data.channel.channel_id}_thumb.jpg`}
|
src={`${API_URL}/cache/channels/${data.data.channel.channel_id}_thumb.jpg`}
|
||||||
alt="channel-thumb"
|
alt="channel-thumb"
|
||||||
width={90}
|
width={90}
|
||||||
height={90}
|
height={90}
|
97
app/session.server.ts
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
import { createCookieSessionStorage, redirect } from "@remix-run/node";
|
||||||
|
import invariant from "tiny-invariant";
|
||||||
|
|
||||||
|
import type { User } from "~/models/user.server";
|
||||||
|
import { getUserById } from "~/models/user.server";
|
||||||
|
|
||||||
|
invariant(process.env.SESSION_SECRET, "SESSION_SECRET must be set");
|
||||||
|
|
||||||
|
export const sessionStorage = createCookieSessionStorage({
|
||||||
|
cookie: {
|
||||||
|
name: "__session",
|
||||||
|
httpOnly: true,
|
||||||
|
path: "/",
|
||||||
|
sameSite: "lax",
|
||||||
|
secrets: [process.env.SESSION_SECRET],
|
||||||
|
secure: process.env.NODE_ENV === "production",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const USER_SESSION_KEY = "userId";
|
||||||
|
|
||||||
|
export async function getSession(request: Request) {
|
||||||
|
const cookie = request.headers.get("Cookie");
|
||||||
|
return sessionStorage.getSession(cookie);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getUserId(
|
||||||
|
request: Request
|
||||||
|
): Promise<User["id"] | undefined> {
|
||||||
|
const session = await getSession(request);
|
||||||
|
const userId = session.get(USER_SESSION_KEY);
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getUser(request: Request) {
|
||||||
|
const userId = await getUserId(request);
|
||||||
|
if (userId === undefined) return null;
|
||||||
|
|
||||||
|
const user = await getUserById(userId);
|
||||||
|
if (user) return user;
|
||||||
|
|
||||||
|
throw await logout(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function requireUserId(
|
||||||
|
request: Request,
|
||||||
|
redirectTo: string = new URL(request.url).pathname
|
||||||
|
) {
|
||||||
|
const userId = await getUserId(request);
|
||||||
|
if (!userId) {
|
||||||
|
const searchParams = new URLSearchParams([["redirectTo", redirectTo]]);
|
||||||
|
throw redirect(`/login?${searchParams}`);
|
||||||
|
}
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function requireUser(request: Request) {
|
||||||
|
const userId = await requireUserId(request);
|
||||||
|
|
||||||
|
const user = await getUserById(userId);
|
||||||
|
if (user) return user;
|
||||||
|
|
||||||
|
throw await logout(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createUserSession({
|
||||||
|
request,
|
||||||
|
userId,
|
||||||
|
remember,
|
||||||
|
redirectTo,
|
||||||
|
}: {
|
||||||
|
request: Request;
|
||||||
|
userId: string;
|
||||||
|
remember: boolean;
|
||||||
|
redirectTo: string;
|
||||||
|
}) {
|
||||||
|
const session = await getSession(request);
|
||||||
|
session.set(USER_SESSION_KEY, userId);
|
||||||
|
return redirect(redirectTo, {
|
||||||
|
headers: {
|
||||||
|
"Set-Cookie": await sessionStorage.commitSession(session, {
|
||||||
|
maxAge: remember
|
||||||
|
? 60 * 60 * 24 * 7 // 7 days
|
||||||
|
: undefined,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function logout(request: Request) {
|
||||||
|
const session = await getSession(request);
|
||||||
|
return redirect("/", {
|
||||||
|
headers: {
|
||||||
|
"Set-Cookie": await sessionStorage.destroySession(session),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
231
src/styles/globals.css → app/styles/globals.css
Executable file → Normal file
@ -1,3 +1,15 @@
|
|||||||
|
@font-face {
|
||||||
|
font-family: "Sen-Bold";
|
||||||
|
src: url("/font/Sen-Bold.woff");
|
||||||
|
font-family: "Sen-Bold";
|
||||||
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: "Sen-Regular";
|
||||||
|
src: url("/font/Sen-Regular.woff");
|
||||||
|
font-family: "Sen-Regular";
|
||||||
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@ -98,10 +110,6 @@ textarea {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-padding {
|
|
||||||
margin: 0 4px 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
button {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
padding: 5px 13px;
|
padding: 5px 13px;
|
||||||
@ -131,6 +139,18 @@ button:hover {
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.boxed-content.boxed-4 {
|
||||||
|
max-width: 1200px;
|
||||||
|
width: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.boxed-content.boxed-5,
|
||||||
|
.boxed-content.boxed-6,
|
||||||
|
.boxed-content.boxed-7 {
|
||||||
|
max-width: unset;
|
||||||
|
width: 85%;
|
||||||
|
}
|
||||||
|
|
||||||
.round-img img {
|
.round-img img {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
@ -325,16 +345,10 @@ button:hover {
|
|||||||
margin: 15px 0;
|
margin: 15px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.view-icons {
|
.view-icons,
|
||||||
|
.grid-count {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: end;
|
||||||
}
|
|
||||||
|
|
||||||
.view-icons-margin {
|
|
||||||
/* width: 30px; */
|
|
||||||
margin: 5px 10px;
|
|
||||||
/* cursor: pointer;
|
|
||||||
filter: var(--img-filter); */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.view-icons img {
|
.view-icons img {
|
||||||
@ -344,15 +358,29 @@ button:hover {
|
|||||||
filter: var(--img-filter);
|
filter: var(--img-filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* #hidden-form {
|
.grid-count img {
|
||||||
|
width: 15px;
|
||||||
|
margin: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
filter: var(--img-filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
#hidden-form {
|
||||||
display: none;
|
display: none;
|
||||||
} */
|
}
|
||||||
|
|
||||||
#text-reveal {
|
#text-reveal {
|
||||||
height: 0px;
|
height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#text-expand {
|
||||||
|
overflow: hidden;
|
||||||
|
display: -webkit-inline-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 4;
|
||||||
|
}
|
||||||
|
|
||||||
/* video player */
|
/* video player */
|
||||||
.player-wrapper {
|
.player-wrapper {
|
||||||
background-color: var(--highlight-bg);
|
background-color: var(--highlight-bg);
|
||||||
@ -391,6 +419,12 @@ button:hover {
|
|||||||
margin: 10px 10px 10px 0;
|
margin: 10px 10px 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* fix for safari full screen not scaling full */
|
||||||
|
video:-webkit-full-screen {
|
||||||
|
max-height: unset !important;
|
||||||
|
max-width: unset !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* video list */
|
/* video list */
|
||||||
.video-list {
|
.video-list {
|
||||||
display: grid;
|
display: grid;
|
||||||
@ -398,10 +432,26 @@ button:hover {
|
|||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.video-list.grid {
|
.video-list.grid.grid-3 {
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.video-list.grid.grid-4 {
|
||||||
|
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-list.grid.grid-5 {
|
||||||
|
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-list.grid.grid-6 {
|
||||||
|
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-list.grid.grid-7 {
|
||||||
|
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
.video-list.list {
|
.video-list.list {
|
||||||
grid-template-columns: unset;
|
grid-template-columns: unset;
|
||||||
}
|
}
|
||||||
@ -410,9 +460,15 @@ button:hover {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.video-item:hover .video-thumb span {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.video-item.list {
|
.video-item.list {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 25% auto;
|
grid-template-columns: 26% auto;
|
||||||
|
background-color: var(--highlight-bg);
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.video-progress-bar {
|
.video-progress-bar {
|
||||||
@ -428,6 +484,16 @@ button:hover {
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.video-thumb span {
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
left: 5px;
|
||||||
|
background-color: var(--accent-font-light);
|
||||||
|
padding: 5px;
|
||||||
|
opacity: 0;
|
||||||
|
transition: 300ms ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
.video-play img {
|
.video-play img {
|
||||||
width: 40px;
|
width: 40px;
|
||||||
filter: var(--img-filter);
|
filter: var(--img-filter);
|
||||||
@ -462,10 +528,9 @@ button:hover {
|
|||||||
|
|
||||||
.video-desc.list {
|
.video-desc.list {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
height: unset;
|
height: 100%;
|
||||||
background-color: var(--highlight-bg);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap-reverse;
|
flex-wrap: wrap;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,8 +592,6 @@ button:hover {
|
|||||||
|
|
||||||
.pagination-item {
|
.pagination-item {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
margin-right: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,6 +621,8 @@ button:hover {
|
|||||||
|
|
||||||
.description-box {
|
.description-box {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
|
padding: 15px;
|
||||||
|
background-color: var(--highlight-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-box-3 {
|
.info-box-3 {
|
||||||
@ -739,6 +804,10 @@ button:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* multi search page */
|
/* multi search page */
|
||||||
|
.multi-search-box {
|
||||||
|
padding-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.multi-search-box input {
|
.multi-search-box input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
@ -784,6 +853,18 @@ button:hover {
|
|||||||
transform: translateX(-30%);
|
transform: translateX(-30%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info-box-item.channel-nav {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-box-item.channel-nav a {
|
||||||
|
padding: 0 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-box-item.channel-nav a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
/* playlist overview page */
|
/* playlist overview page */
|
||||||
.playlist-list.list {
|
.playlist-list.list {
|
||||||
display: grid;
|
display: grid;
|
||||||
@ -842,73 +923,6 @@ button:hover {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dl-list.list {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-list.grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
|
||||||
grid-gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-item.list {
|
|
||||||
display: flex;
|
|
||||||
margin: 15px 0;
|
|
||||||
align-items: center;
|
|
||||||
background-color: var(--highlight-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-item.grid {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
background-color: var(--highlight-bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-check {
|
|
||||||
width: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-item:hover > .dl-thumb span {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-thumb {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-thumb span {
|
|
||||||
position: absolute;
|
|
||||||
top: 5px;
|
|
||||||
left: 5px;
|
|
||||||
background-color: var(--accent-font-light);
|
|
||||||
padding: 5px;
|
|
||||||
opacity: 0;
|
|
||||||
transition: 300ms ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-thumb.list {
|
|
||||||
width: 25%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-thumb.grid {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-item img {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-desc.list {
|
|
||||||
padding: 0 15px;
|
|
||||||
width: 75%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-desc.grid {
|
|
||||||
padding: 15px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dl-control-icons {
|
.dl-control-icons {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@ -1053,19 +1067,23 @@ button:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* tablet */
|
/* tablet */
|
||||||
@media screen and (max-width: 1000px) {
|
@media screen and (max-width: 1000px), screen and (max-height: 850px) {
|
||||||
.boxed-content {
|
.boxed-content,
|
||||||
|
.boxed-content.boxed-4,
|
||||||
|
.boxed-content.boxed-5,
|
||||||
|
.boxed-content.boxed-6,
|
||||||
|
.boxed-content.boxed-7 {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
}
|
}
|
||||||
.video-list.grid,
|
.video-list.grid.grid-3,
|
||||||
.dl-list.grid,
|
.video-list.grid.grid-4,
|
||||||
|
.video-list.grid.grid-5,
|
||||||
|
.video-list.grid.grid-6,
|
||||||
|
.video-list.grid.grid-7,
|
||||||
.channel-list.grid,
|
.channel-list.grid,
|
||||||
.playlist-list.grid {
|
.playlist-list.grid {
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr;
|
||||||
}
|
}
|
||||||
.dl-thumb.list {
|
|
||||||
width: 35%;
|
|
||||||
}
|
|
||||||
.video-item.list,
|
.video-item.list,
|
||||||
.playlist-item.list {
|
.playlist-item.list {
|
||||||
display: grid;
|
display: grid;
|
||||||
@ -1087,6 +1105,9 @@ button:hover {
|
|||||||
position: unset;
|
position: unset;
|
||||||
transform: unset;
|
transform: unset;
|
||||||
}
|
}
|
||||||
|
.grid-count {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
.video-player {
|
.video-player {
|
||||||
height: unset;
|
height: unset;
|
||||||
padding: 20px 0;
|
padding: 20px 0;
|
||||||
@ -1101,8 +1122,11 @@ button:hover {
|
|||||||
* {
|
* {
|
||||||
word-wrap: anywhere;
|
word-wrap: anywhere;
|
||||||
}
|
}
|
||||||
.video-list.grid,
|
.video-list.grid.grid-3,
|
||||||
.dl-list.grid,
|
.video-list.grid.grid-4,
|
||||||
|
.video-list.grid.grid-5,
|
||||||
|
.video-list.grid.grid-6,
|
||||||
|
.video-list.grid.grid-7,
|
||||||
.channel-list.grid,
|
.channel-list.grid,
|
||||||
.video-item.list,
|
.video-item.list,
|
||||||
.playlist-list.list,
|
.playlist-list.list,
|
||||||
@ -1151,15 +1175,6 @@ button:hover {
|
|||||||
.description-box {
|
.description-box {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.dl-item {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.dl-thumb {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.dl-desc {
|
|
||||||
padding: 15px;
|
|
||||||
}
|
|
||||||
.backup-grid-row {
|
.backup-grid-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
136
app/types/Videos.ts
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
export interface Videos {
|
||||||
|
data: Datum[];
|
||||||
|
config: Config;
|
||||||
|
paginate: Paginate;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Config {
|
||||||
|
archive: Archive;
|
||||||
|
default_view: DefaultView;
|
||||||
|
subscriptions: Subscriptions;
|
||||||
|
downloads: Downloads;
|
||||||
|
application: Application;
|
||||||
|
scheduler: Scheduler;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Application {
|
||||||
|
app_root: string;
|
||||||
|
cache_dir: string;
|
||||||
|
videos: string;
|
||||||
|
colors: string;
|
||||||
|
enable_cast: boolean;
|
||||||
|
REDIS_HOST: string;
|
||||||
|
es_url: string;
|
||||||
|
es_auth: string[];
|
||||||
|
HOST_UID: number;
|
||||||
|
HOST_GID: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Archive {
|
||||||
|
sort_by: string;
|
||||||
|
sort_order: string;
|
||||||
|
page_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DefaultView {
|
||||||
|
home: string;
|
||||||
|
channel: string;
|
||||||
|
downloads: string;
|
||||||
|
playlist: string;
|
||||||
|
grid_items: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Downloads {
|
||||||
|
limit_count: boolean;
|
||||||
|
limit_speed: boolean;
|
||||||
|
sleep_interval: number;
|
||||||
|
autodelete_days: boolean;
|
||||||
|
format: boolean;
|
||||||
|
add_metadata: boolean;
|
||||||
|
add_thumbnail: boolean;
|
||||||
|
subtitle: boolean;
|
||||||
|
subtitle_source: boolean;
|
||||||
|
subtitle_index: boolean;
|
||||||
|
cookie_import: boolean;
|
||||||
|
throttledratelimit: boolean;
|
||||||
|
integrate_ryd: boolean;
|
||||||
|
integrate_sponsorblock: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Scheduler {
|
||||||
|
update_subscribed: boolean;
|
||||||
|
download_pending: boolean;
|
||||||
|
check_reindex: CheckReindex;
|
||||||
|
check_reindex_days: number;
|
||||||
|
thumbnail_check: CheckReindex;
|
||||||
|
run_backup: CheckReindex;
|
||||||
|
run_backup_rotate: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CheckReindex {
|
||||||
|
minute: string;
|
||||||
|
hour: string;
|
||||||
|
day_of_week: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Subscriptions {
|
||||||
|
auto_search: boolean;
|
||||||
|
auto_download: boolean;
|
||||||
|
channel_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Datum {
|
||||||
|
active: boolean;
|
||||||
|
category: string[];
|
||||||
|
channel: Channel;
|
||||||
|
date_downloaded: number;
|
||||||
|
description: string;
|
||||||
|
media_url: string;
|
||||||
|
player: Player;
|
||||||
|
published: string;
|
||||||
|
stats: Stats;
|
||||||
|
tags: string[];
|
||||||
|
title: string;
|
||||||
|
vid_last_refresh: string;
|
||||||
|
vid_thumb_base64: boolean;
|
||||||
|
vid_thumb_url: string;
|
||||||
|
youtube_id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Channel {
|
||||||
|
channel_active: boolean;
|
||||||
|
channel_banner_url: string;
|
||||||
|
channel_description: string;
|
||||||
|
channel_id: string;
|
||||||
|
channel_last_refresh: string;
|
||||||
|
channel_name: string;
|
||||||
|
channel_subs: number;
|
||||||
|
channel_subscribed: boolean;
|
||||||
|
channel_thumb_url: string;
|
||||||
|
channel_tvart_url: boolean;
|
||||||
|
channel_views: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Player {
|
||||||
|
watched: boolean;
|
||||||
|
duration: number;
|
||||||
|
duration_str: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Stats {
|
||||||
|
view_count: number;
|
||||||
|
like_count: number;
|
||||||
|
dislike_count: number;
|
||||||
|
average_rating: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Paginate {
|
||||||
|
page_size: number;
|
||||||
|
page_from: number;
|
||||||
|
prev_pages: boolean;
|
||||||
|
current_page: number;
|
||||||
|
max_hits: boolean;
|
||||||
|
last_page: boolean;
|
||||||
|
next_pages: any[];
|
||||||
|
total_hits: number;
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
export interface Channel {
|
export interface Channel {
|
||||||
data: Datum[];
|
data: Data;
|
||||||
config: Config;
|
config: Config;
|
||||||
paginate: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Config {
|
export interface Config {
|
||||||
@ -17,7 +16,6 @@ export interface Application {
|
|||||||
app_root: string;
|
app_root: string;
|
||||||
cache_dir: string;
|
cache_dir: string;
|
||||||
videos: string;
|
videos: string;
|
||||||
file_template: string;
|
|
||||||
colors: string;
|
colors: string;
|
||||||
enable_cast: boolean;
|
enable_cast: boolean;
|
||||||
REDIS_HOST: string;
|
REDIS_HOST: string;
|
||||||
@ -38,6 +36,7 @@ export interface DefaultView {
|
|||||||
channel: string;
|
channel: string;
|
||||||
downloads: string;
|
downloads: string;
|
||||||
playlist: string;
|
playlist: string;
|
||||||
|
grid_items: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Downloads {
|
export interface Downloads {
|
||||||
@ -45,12 +44,13 @@ export interface Downloads {
|
|||||||
limit_speed: boolean;
|
limit_speed: boolean;
|
||||||
sleep_interval: number;
|
sleep_interval: number;
|
||||||
autodelete_days: boolean;
|
autodelete_days: boolean;
|
||||||
format: boolean;
|
format: string;
|
||||||
add_metadata: boolean;
|
add_metadata: boolean;
|
||||||
add_thumbnail: boolean;
|
add_thumbnail: boolean;
|
||||||
subtitle: boolean;
|
subtitle: boolean;
|
||||||
subtitle_source: boolean;
|
subtitle_source: boolean;
|
||||||
subtitle_index: boolean;
|
subtitle_index: boolean;
|
||||||
|
cookie_import: boolean;
|
||||||
throttledratelimit: boolean;
|
throttledratelimit: boolean;
|
||||||
integrate_ryd: boolean;
|
integrate_ryd: boolean;
|
||||||
integrate_sponsorblock: boolean;
|
integrate_sponsorblock: boolean;
|
||||||
@ -78,7 +78,7 @@ export interface Subscriptions {
|
|||||||
channel_size: number;
|
channel_size: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Datum {
|
export interface Data {
|
||||||
channel_active: boolean;
|
channel_active: boolean;
|
||||||
channel_banner_url: string;
|
channel_banner_url: string;
|
||||||
channel_description: string;
|
channel_description: string;
|
106
app/types/channels.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
export interface Channels {
|
||||||
|
data: Datum[];
|
||||||
|
config: Config;
|
||||||
|
paginate: Paginate;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Config {
|
||||||
|
archive: Archive;
|
||||||
|
default_view: DefaultView;
|
||||||
|
subscriptions: Subscriptions;
|
||||||
|
downloads: Downloads;
|
||||||
|
application: Application;
|
||||||
|
scheduler: Scheduler;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Application {
|
||||||
|
app_root: string;
|
||||||
|
cache_dir: string;
|
||||||
|
videos: string;
|
||||||
|
colors: string;
|
||||||
|
enable_cast: boolean;
|
||||||
|
REDIS_HOST: string;
|
||||||
|
es_url: string;
|
||||||
|
es_auth: string[];
|
||||||
|
HOST_UID: number;
|
||||||
|
HOST_GID: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Archive {
|
||||||
|
sort_by: string;
|
||||||
|
sort_order: string;
|
||||||
|
page_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DefaultView {
|
||||||
|
home: string;
|
||||||
|
channel: string;
|
||||||
|
downloads: string;
|
||||||
|
playlist: string;
|
||||||
|
grid_items: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Downloads {
|
||||||
|
limit_count: boolean;
|
||||||
|
limit_speed: boolean;
|
||||||
|
sleep_interval: number;
|
||||||
|
autodelete_days: boolean;
|
||||||
|
format: string;
|
||||||
|
add_metadata: boolean;
|
||||||
|
add_thumbnail: boolean;
|
||||||
|
subtitle: boolean;
|
||||||
|
subtitle_source: boolean;
|
||||||
|
subtitle_index: boolean;
|
||||||
|
cookie_import: boolean;
|
||||||
|
throttledratelimit: boolean;
|
||||||
|
integrate_ryd: boolean;
|
||||||
|
integrate_sponsorblock: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Scheduler {
|
||||||
|
update_subscribed: boolean;
|
||||||
|
download_pending: boolean;
|
||||||
|
check_reindex: CheckReindex;
|
||||||
|
check_reindex_days: number;
|
||||||
|
thumbnail_check: CheckReindex;
|
||||||
|
run_backup: CheckReindex;
|
||||||
|
run_backup_rotate: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CheckReindex {
|
||||||
|
minute: string;
|
||||||
|
hour: string;
|
||||||
|
day_of_week: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Subscriptions {
|
||||||
|
auto_search: boolean;
|
||||||
|
auto_download: boolean;
|
||||||
|
channel_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Datum {
|
||||||
|
channel_active: boolean;
|
||||||
|
channel_banner_url: string;
|
||||||
|
channel_description: string;
|
||||||
|
channel_id: string;
|
||||||
|
channel_last_refresh: string;
|
||||||
|
channel_name: string;
|
||||||
|
channel_subs: number;
|
||||||
|
channel_subscribed: boolean;
|
||||||
|
channel_thumb_url: string;
|
||||||
|
channel_tvart_url: boolean;
|
||||||
|
channel_views: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Paginate {
|
||||||
|
page_size: number;
|
||||||
|
page_from: number;
|
||||||
|
prev_pages: boolean;
|
||||||
|
current_page: number;
|
||||||
|
max_hits: boolean;
|
||||||
|
params: string;
|
||||||
|
last_page: boolean;
|
||||||
|
next_pages: any[];
|
||||||
|
total_hits: number;
|
||||||
|
}
|
0
src/types/download.ts → app/types/download.ts
Executable file → Normal file
104
app/types/playlist.ts
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
export interface Playlist {
|
||||||
|
data: Data;
|
||||||
|
config: Config;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Config {
|
||||||
|
archive: Archive;
|
||||||
|
default_view: DefaultView;
|
||||||
|
subscriptions: Subscriptions;
|
||||||
|
downloads: Downloads;
|
||||||
|
application: Application;
|
||||||
|
scheduler: Scheduler;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Application {
|
||||||
|
app_root: string;
|
||||||
|
cache_dir: string;
|
||||||
|
videos: string;
|
||||||
|
colors: string;
|
||||||
|
enable_cast: boolean;
|
||||||
|
REDIS_HOST: string;
|
||||||
|
es_url: string;
|
||||||
|
es_auth: string[];
|
||||||
|
HOST_UID: number;
|
||||||
|
HOST_GID: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Archive {
|
||||||
|
sort_by: string;
|
||||||
|
sort_order: string;
|
||||||
|
page_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DefaultView {
|
||||||
|
home: string;
|
||||||
|
channel: string;
|
||||||
|
downloads: string;
|
||||||
|
playlist: string;
|
||||||
|
grid_items: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Downloads {
|
||||||
|
limit_count: boolean;
|
||||||
|
limit_speed: boolean;
|
||||||
|
sleep_interval: number;
|
||||||
|
autodelete_days: boolean;
|
||||||
|
format: string;
|
||||||
|
add_metadata: boolean;
|
||||||
|
add_thumbnail: boolean;
|
||||||
|
subtitle: boolean;
|
||||||
|
subtitle_source: boolean;
|
||||||
|
subtitle_index: boolean;
|
||||||
|
cookie_import: boolean;
|
||||||
|
throttledratelimit: boolean;
|
||||||
|
integrate_ryd: boolean;
|
||||||
|
integrate_sponsorblock: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Scheduler {
|
||||||
|
update_subscribed: boolean;
|
||||||
|
download_pending: boolean;
|
||||||
|
check_reindex: CheckReindex;
|
||||||
|
check_reindex_days: number;
|
||||||
|
thumbnail_check: CheckReindex;
|
||||||
|
run_backup: CheckReindex;
|
||||||
|
run_backup_rotate: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CheckReindex {
|
||||||
|
minute: string;
|
||||||
|
hour: string;
|
||||||
|
day_of_week: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Subscriptions {
|
||||||
|
auto_search: boolean;
|
||||||
|
auto_download: boolean;
|
||||||
|
channel_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Data {
|
||||||
|
playlist_active: boolean;
|
||||||
|
playlist_channel: PlaylistChannel;
|
||||||
|
playlist_channel_id: string;
|
||||||
|
playlist_description: string;
|
||||||
|
playlist_entries: PlaylistEntry[];
|
||||||
|
playlist_id: string;
|
||||||
|
playlist_last_refresh: string;
|
||||||
|
playlist_name: string;
|
||||||
|
playlist_subscribed: boolean;
|
||||||
|
playlist_thumbnail: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum PlaylistChannel {
|
||||||
|
Markiplier = "Markiplier",
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlaylistEntry {
|
||||||
|
youtube_id: string;
|
||||||
|
title: string;
|
||||||
|
uploader: PlaylistChannel;
|
||||||
|
idx: number;
|
||||||
|
downloaded: boolean;
|
||||||
|
}
|
138
app/types/playlistVideos.ts
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
export interface PlaylistVideos {
|
||||||
|
data: Datum[];
|
||||||
|
config: Config;
|
||||||
|
paginate: Paginate;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Config {
|
||||||
|
archive: Archive;
|
||||||
|
default_view: DefaultView;
|
||||||
|
subscriptions: Subscriptions;
|
||||||
|
downloads: Downloads;
|
||||||
|
application: Application;
|
||||||
|
scheduler: Scheduler;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Application {
|
||||||
|
app_root: string;
|
||||||
|
cache_dir: string;
|
||||||
|
videos: string;
|
||||||
|
colors: string;
|
||||||
|
enable_cast: boolean;
|
||||||
|
REDIS_HOST: string;
|
||||||
|
es_url: string;
|
||||||
|
es_auth: string[];
|
||||||
|
HOST_UID: number;
|
||||||
|
HOST_GID: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Archive {
|
||||||
|
sort_by: string;
|
||||||
|
sort_order: string;
|
||||||
|
page_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DefaultView {
|
||||||
|
home: string;
|
||||||
|
channel: string;
|
||||||
|
downloads: string;
|
||||||
|
playlist: string;
|
||||||
|
grid_items: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Downloads {
|
||||||
|
limit_count: boolean;
|
||||||
|
limit_speed: boolean;
|
||||||
|
sleep_interval: number;
|
||||||
|
autodelete_days: boolean;
|
||||||
|
format: string;
|
||||||
|
add_metadata: boolean;
|
||||||
|
add_thumbnail: boolean;
|
||||||
|
subtitle: boolean;
|
||||||
|
subtitle_source: boolean;
|
||||||
|
subtitle_index: boolean;
|
||||||
|
cookie_import: boolean;
|
||||||
|
throttledratelimit: boolean;
|
||||||
|
integrate_ryd: boolean;
|
||||||
|
integrate_sponsorblock: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Scheduler {
|
||||||
|
update_subscribed: boolean;
|
||||||
|
download_pending: boolean;
|
||||||
|
check_reindex: CheckReindex;
|
||||||
|
check_reindex_days: number;
|
||||||
|
thumbnail_check: CheckReindex;
|
||||||
|
run_backup: CheckReindex;
|
||||||
|
run_backup_rotate: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CheckReindex {
|
||||||
|
minute: string;
|
||||||
|
hour: string;
|
||||||
|
day_of_week: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Subscriptions {
|
||||||
|
auto_search: boolean;
|
||||||
|
auto_download: boolean;
|
||||||
|
channel_size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Datum {
|
||||||
|
active: boolean;
|
||||||
|
category: string[];
|
||||||
|
channel: Channel;
|
||||||
|
date_downloaded: number;
|
||||||
|
description: string;
|
||||||
|
media_url: string;
|
||||||
|
player: Player;
|
||||||
|
playlist: string[];
|
||||||
|
published: string;
|
||||||
|
stats: Stats;
|
||||||
|
tags: string[];
|
||||||
|
title: string;
|
||||||
|
vid_last_refresh: string;
|
||||||
|
vid_thumb_base64: boolean;
|
||||||
|
vid_thumb_url: string;
|
||||||
|
youtube_id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Channel {
|
||||||
|
channel_active: boolean;
|
||||||
|
channel_banner_url: string;
|
||||||
|
channel_description: string;
|
||||||
|
channel_id: string;
|
||||||
|
channel_last_refresh: string;
|
||||||
|
channel_name: string;
|
||||||
|
channel_subs: number;
|
||||||
|
channel_subscribed: boolean;
|
||||||
|
channel_thumb_url: string;
|
||||||
|
channel_tvart_url: boolean;
|
||||||
|
channel_views: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Player {
|
||||||
|
watched: boolean;
|
||||||
|
duration: number;
|
||||||
|
duration_str: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Stats {
|
||||||
|
view_count: number;
|
||||||
|
like_count: number;
|
||||||
|
dislike_count: number;
|
||||||
|
average_rating: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Paginate {
|
||||||
|
page_size: number;
|
||||||
|
page_from: number;
|
||||||
|
prev_pages: boolean;
|
||||||
|
current_page: number;
|
||||||
|
max_hits: boolean;
|
||||||
|
params: string;
|
||||||
|
last_page: boolean;
|
||||||
|
next_pages: any[];
|
||||||
|
total_hits: number;
|
||||||
|
}
|
13
app/utils.test.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { validateEmail } from "./utils";
|
||||||
|
|
||||||
|
test("validateEmail returns false for non-emails", () => {
|
||||||
|
expect(validateEmail(undefined)).toBe(false);
|
||||||
|
expect(validateEmail(null)).toBe(false);
|
||||||
|
expect(validateEmail("")).toBe(false);
|
||||||
|
expect(validateEmail("not-an-email")).toBe(false);
|
||||||
|
expect(validateEmail("n@")).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("validateEmail returns true for emails", () => {
|
||||||
|
expect(validateEmail("kody@example.com")).toBe(true);
|
||||||
|
});
|
71
app/utils.ts
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { useMatches } from "@remix-run/react";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
|
||||||
|
import type { User } from "~/models/user.server";
|
||||||
|
|
||||||
|
const DEFAULT_REDIRECT = "/";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This should be used any time the redirect path is user-provided
|
||||||
|
* (Like the query string on our login/signup pages). This avoids
|
||||||
|
* open-redirect vulnerabilities.
|
||||||
|
* @param {string} to The redirect destination
|
||||||
|
* @param {string} defaultRedirect The redirect to use if the to is unsafe.
|
||||||
|
*/
|
||||||
|
export function safeRedirect(
|
||||||
|
to: FormDataEntryValue | string | null | undefined,
|
||||||
|
defaultRedirect: string = DEFAULT_REDIRECT
|
||||||
|
) {
|
||||||
|
if (!to || typeof to !== "string") {
|
||||||
|
return defaultRedirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!to.startsWith("/") || to.startsWith("//")) {
|
||||||
|
return defaultRedirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
return to;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This base hook is used in other hooks to quickly search for specific data
|
||||||
|
* across all loader data using useMatches.
|
||||||
|
* @param {string} id The route id
|
||||||
|
* @returns {JSON|undefined} The router data or undefined if not found
|
||||||
|
*/
|
||||||
|
export function useMatchesData(
|
||||||
|
id: string
|
||||||
|
): Record<string, unknown> | undefined {
|
||||||
|
const matchingRoutes = useMatches();
|
||||||
|
const route = useMemo(
|
||||||
|
() => matchingRoutes.find((route) => route.id === id),
|
||||||
|
[matchingRoutes, id]
|
||||||
|
);
|
||||||
|
return route?.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isUser(user: any): user is User {
|
||||||
|
return user && typeof user === "object" && typeof user.email === "string";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useOptionalUser(): User | undefined {
|
||||||
|
const data = useMatchesData("root");
|
||||||
|
if (!data || !isUser(data.user)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return data.user;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUser(): User {
|
||||||
|
const maybeUser = useOptionalUser();
|
||||||
|
if (!maybeUser) {
|
||||||
|
throw new Error(
|
||||||
|
"No user found in root loader, but user is required by useUser. If user is optional, try useOptionalUser instead."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return maybeUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function validateEmail(email: unknown): email is string {
|
||||||
|
return typeof email === "string" && email.length > 3 && email.includes("@");
|
||||||
|
}
|
Before Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 113 KiB |
Before Width: | Height: | Size: 80 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 83 KiB |
Before Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 131 KiB |
Before Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 174 KiB |
Before Width: | Height: | Size: 166 KiB |
Before Width: | Height: | Size: 238 KiB |
Before Width: | Height: | Size: 52 KiB |
27
cypress.config.ts
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import { defineConfig } from "cypress";
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
e2e: {
|
||||||
|
setupNodeEvents: (on, config) => {
|
||||||
|
const isDev = config.watchForFileChanges;
|
||||||
|
const port = process.env.PORT ?? (isDev ? "3000" : "8811");
|
||||||
|
const configOverrides: Partial<Cypress.PluginConfigOptions> = {
|
||||||
|
baseUrl: `http://localhost:${port}`,
|
||||||
|
video: !process.env.CI,
|
||||||
|
screenshotOnRunFailure: !process.env.CI,
|
||||||
|
};
|
||||||
|
|
||||||
|
// To use this:
|
||||||
|
// cy.task('log', whateverYouWantInTheTerminal)
|
||||||
|
on("task", {
|
||||||
|
log: (message) => {
|
||||||
|
console.log(message);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return { ...config, ...configOverrides };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
6
cypress/.eslintrc.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
parserOptions: {
|
||||||
|
tsconfigRootDir: __dirname,
|
||||||
|
project: "./tsconfig.json",
|
||||||
|
},
|
||||||
|
};
|
51
cypress/e2e/smoke.cy.ts
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { faker } from "@faker-js/faker";
|
||||||
|
|
||||||
|
describe("smoke tests", () => {
|
||||||
|
afterEach(() => {
|
||||||
|
cy.cleanupUser();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should allow you to register and login", () => {
|
||||||
|
const loginForm = {
|
||||||
|
email: `${faker.internet.userName()}@example.com`,
|
||||||
|
password: faker.internet.password(),
|
||||||
|
};
|
||||||
|
|
||||||
|
cy.then(() => ({ email: loginForm.email })).as("user");
|
||||||
|
|
||||||
|
cy.visitAndCheck("/");
|
||||||
|
|
||||||
|
cy.findByRole("link", { name: /sign up/i }).click();
|
||||||
|
|
||||||
|
cy.findByRole("textbox", { name: /email/i }).type(loginForm.email);
|
||||||
|
cy.findByLabelText(/password/i).type(loginForm.password);
|
||||||
|
cy.findByRole("button", { name: /create account/i }).click();
|
||||||
|
|
||||||
|
cy.findByRole("link", { name: /notes/i }).click();
|
||||||
|
cy.findByRole("button", { name: /logout/i }).click();
|
||||||
|
cy.findByRole("link", { name: /log in/i });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should allow you to make a note", () => {
|
||||||
|
const testNote = {
|
||||||
|
title: faker.lorem.words(1),
|
||||||
|
body: faker.lorem.sentences(1),
|
||||||
|
};
|
||||||
|
cy.login();
|
||||||
|
|
||||||
|
cy.visitAndCheck("/");
|
||||||
|
|
||||||
|
cy.findByRole("link", { name: /notes/i }).click();
|
||||||
|
cy.findByText("No notes yet");
|
||||||
|
|
||||||
|
cy.findByRole("link", { name: /\+ new note/i }).click();
|
||||||
|
|
||||||
|
cy.findByRole("textbox", { name: /title/i }).type(testNote.title);
|
||||||
|
cy.findByRole("textbox", { name: /body/i }).type(testNote.body);
|
||||||
|
cy.findByRole("button", { name: /save/i }).click();
|
||||||
|
|
||||||
|
cy.findByRole("button", { name: /delete/i }).click();
|
||||||
|
|
||||||
|
cy.findByText("No notes yet");
|
||||||
|
});
|
||||||
|
});
|
5
cypress/fixtures/example.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"name": "Using fixtures to represent data",
|
||||||
|
"email": "hello@cypress.io",
|
||||||
|
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||||
|
}
|