Working on new UI

This commit is contained in:
Sebastiaan de Schaetzen 2025-06-17 09:21:25 +02:00
parent 91be8274c4
commit 9100d11bbf
4 changed files with 494 additions and 260 deletions

46
go.mod
View File

@ -5,24 +5,50 @@ go 1.24
toolchain go1.24.0
require (
gitea.seeseepuff.be/seeseemelk/mysqlite v0.7.0
gitea.seeseepuff.be/seeseemelk/mysqlite v0.15.0
github.com/donseba/go-htmx v1.12.0
github.com/playwright-community/playwright-go v0.4902.0
github.com/gin-gonic/gin v1.10.1
github.com/playwright-community/playwright-go v0.5200.0
)
require (
github.com/deckarep/golang-set/v2 v2.7.0 // indirect
github.com/bytedance/sonic v1.13.3 // indirect
github.com/bytedance/sonic/loader v0.2.4 // indirect
github.com/cloudwego/base64x v0.1.5 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/deckarep/golang-set/v2 v2.8.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.4 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.26.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
golang.org/x/sys v0.22.0 // indirect
modernc.org/libc v1.55.3 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/sqlite v1.33.1 // indirect
zombiezen.com/go/sqlite v1.4.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.3.0 // indirect
golang.org/x/arch v0.18.0 // indirect
golang.org/x/crypto v0.39.0 // indirect
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 // indirect
golang.org/x/net v0.41.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.26.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/libc v1.65.10 // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
modernc.org/sqlite v1.38.0 // indirect
zombiezen.com/go/sqlite v1.4.2 // indirect
)

85
go.sum
View File

@ -1,51 +1,117 @@
gitea.seeseepuff.be/seeseemelk/mysqlite v0.7.0 h1:gq75Ce7QTQ5Rj5fzS/6eeOA/enyV0oDMVt5mejwX14Y=
gitea.seeseepuff.be/seeseemelk/mysqlite v0.7.0/go.mod h1:cgswydOxJjMlNwfcBIXnKjr47LwXnMT9BInkiHb0tXE=
gitea.seeseepuff.be/seeseemelk/mysqlite v0.15.0 h1:+k0iBYM/aZJxz7++EKi/G9e66E9u4bPS3DFLrBeDb9Y=
gitea.seeseepuff.be/seeseemelk/mysqlite v0.15.0/go.mod h1:cgswydOxJjMlNwfcBIXnKjr47LwXnMT9BInkiHb0tXE=
github.com/bytedance/sonic v1.13.3 h1:MS8gmaH16Gtirygw7jV91pDCN33NyMrPbN7qiYhEsF0=
github.com/bytedance/sonic v1.13.3/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckarep/golang-set/v2 v2.7.0 h1:gIloKvD7yH2oip4VLhsv3JyLLFnC0Y2mlusgcvJYW5k=
github.com/deckarep/golang-set/v2 v2.7.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
github.com/deckarep/golang-set/v2 v2.8.0 h1:swm0rlPCmdWn9mESxKOjWk8hXSqoxOp+ZlfuyaAdFlQ=
github.com/deckarep/golang-set/v2 v2.8.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
github.com/donseba/go-htmx v1.12.0 h1:7tESER0uxaqsuGMv3yP3pK1drfBUXM6apG4H7/3+IgE=
github.com/donseba/go-htmx v1.12.0/go.mod h1:8PTAYvNKf8+QYis+DpAsggKz+sa2qljtMgvdAeNBh5s=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k=
github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ=
github.com/go-jose/go-jose/v3 v3.0.4 h1:Wp5HA7bLQcKnf6YYao/4kpRpVMp/yf6+pJKV8WFSaNY=
github.com/go-jose/go-jose/v3 v3.0.4/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mitchellh/go-ps v1.0.0 h1:i6ampVEEF4wQFF+bkYfwYgY+F/uYJDktmvLPf7qIgjc=
github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/playwright-community/playwright-go v0.4902.0 h1:SslPUKmc35YgTBZKTLhokxrqTsVk3/mirj+TkqR6dC0=
github.com/playwright-community/playwright-go v0.4902.0/go.mod h1:kBNWs/w2aJ2ZUp1wEOOFLXgOqvppFngM5OS+qyhl+ZM=
github.com/playwright-community/playwright-go v0.5200.0 h1:z/5LGuX2tBrg3ug1HupMXLjIG93f1d2MWdDsNhkMQ9c=
github.com/playwright-community/playwright-go v0.5200.0/go.mod h1:UnnyQZaqUOO5ywAZu60+N4EiWReUqX1MQBBA3Oofvf8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/arch v0.18.0 h1:WN9poc33zL4AzGxqf8VtpKUnGvMi8O9lhNyBMF/85qc=
golang.org/x/arch v0.18.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 h1:bsqhLWFR6G6xiQcb+JoGqdKdRU6WzPWmK8E0jxTjzo4=
golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -60,6 +126,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
@ -72,6 +140,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
@ -79,6 +149,8 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
@ -89,23 +161,36 @@ modernc.org/ccgo/v4 v4.19.2 h1:lwQZgvboKD0jBwdaeVCTouxhxAyN6iawF3STraAal8Y=
modernc.org/ccgo/v4 v4.19.2/go.mod h1:ysS3mxiMV38XGRTTcgo0DQTeTmAO4oCmJl1nX9VFI3s=
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
modernc.org/fileutil v1.3.3 h1:3qaU+7f7xxTUmvU1pJTZiDLAIoJVdUSSauJNHg9yXoA=
modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw=
modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU=
modernc.org/libc v1.55.3 h1:AzcW1mhlPNrRtjS5sS+eW2ISCgSOLLNyFzRh/V3Qj/U=
modernc.org/libc v1.55.3/go.mod h1:qFXepLhz+JjFThQ4kzwzOjA/y/artDeg+pcYnY+Q83w=
modernc.org/libc v1.65.10 h1:ZwEk8+jhW7qBjHIT+wd0d9VjitRyQef9BnzlzGwMODc=
modernc.org/libc v1.65.10/go.mod h1:StFvYpx7i/mXtBAfVOjaU0PWZOvIRoZSgXhrwXzr8Po=
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc=
modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss=
modernc.org/sqlite v1.33.1 h1:trb6Z3YYoeM9eDL1O8do81kP+0ejv+YzgyFo+Gwy0nM=
modernc.org/sqlite v1.33.1/go.mod h1:pXV2xHxhzXZsgT/RtTFAPY6JJDEvOTcTdwADQCCWD4k=
modernc.org/sqlite v1.38.0 h1:+4OrfPQ8pxHKuWG4md1JpR/EYAh3Md7TdejuuzE7EUI=
modernc.org/sqlite v1.38.0/go.mod h1:1Bj+yES4SVvBZ4cBOpVZ6QgesMCKpJZDq0nxYzOpmNE=
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
zombiezen.com/go/sqlite v1.4.0 h1:N1s3RIljwtp4541Y8rM880qgGIgq3fTD2yks1xftnKU=
zombiezen.com/go/sqlite v1.4.0/go.mod h1:0w9F1DN9IZj9AcLS9YDKMboubCACkwYCGkzoy3eG5ik=
zombiezen.com/go/sqlite v1.4.2 h1:KZXLrBuJ7tKNEm+VJcApLMeQbhmAUOKA5VWS93DfFRo=
zombiezen.com/go/sqlite v1.4.2/go.mod h1:5Kd4taTAD4MkBzT25mQ9uaAlLjyR0rFhsR6iINO70jc=

96
static/index.html Normal file
View File

@ -0,0 +1,96 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Viva++</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<style>
body {
background-color: #000;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.loader {
border: 1.5vw solid #333;
border-top: 1.5vw solid #3498db;
border-bottom: 1.5vw solid #3498db;
border-radius: 50%;
width: 10vw;
height: 10vw;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.video-container {
display: none;
width: 100%;
justify-content: center;
align-items: center;
gap: 2vw;
}
.video-thumbnail {
border-radius: 8px;
transition: transform 0.3s ease;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
background-color: #444;
aspect-ratio: 16/9;
object-fit: cover;
}
.current-video {
width: 50vw;
z-index: 2;
box-shadow: 0 0 200px -10px #444;
}
.side-video {
width: 20vw;
opacity: 0.7;
z-index: 1;
}
</style>
<script>
function hideLoader() {
$(".loader").hide();
$(".video-container").css("display", "flex");
}
$(document).ready(function() {
// Pre-set all thumbnails to a placeholder state
$(".video-thumbnail").attr("src", "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25' viewBox='0 0 16 9'%3E%3C/svg%3E");
$.getJSON("/api/homepage", function(data) {
let currentVideo = data.currentVideo;
// previousVideo = data.previousVideo;
// nextVideo = data.nextVideo;
//
// // Set thumbnails
$("#current-thumb").attr("src", currentVideo.thumbnail);
// $("#prev-thumb").attr("src", previousVideo.thumbnail);
// $("#next-thumb").attr("src", nextVideo.thumbnail);
// Hide loader and show videos
hideLoader();
})
})
</script>
</head>
<body>
<div class="loader" id="loader"></div>
<div class="video-container">
<img id="prev-thumb" class="video-thumbnail side-video" alt="Previous Video">
<img id="current-thumb" class="video-thumbnail current-video" alt="Current Video">
<img id="next-thumb" class="video-thumbnail side-video" alt="Next Video">
</div>
</body>
</html>

View File

@ -1,16 +1,10 @@
package main
import (
"fmt"
"log"
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
"gitea.seeseepuff.be/seeseemelk/mysqlite"
"github.com/donseba/go-htmx"
"github.com/gin-gonic/gin"
"log"
)
type App struct {
@ -22,261 +16,294 @@ func serveWebview(db *mysqlite.Db) {
addr := "localhost:8081"
app := &App{
db: db,
htmx: htmx.New(),
db: db,
}
log.Printf("Listening on %s", addr)
http.Handle("/static/", http.StripPrefix("/static/", staticFileServer()))
http.HandleFunc("/video/", app.serveVideo)
http.HandleFunc("/stream/", app.serveStream)
http.HandleFunc("/mark-watched/", app.handleMarkWatched)
http.HandleFunc("/mark-unwatched/", app.handleMarkUnwatched)
http.HandleFunc("/", app.serveIndex)
err := http.ListenAndServe(addr, nil)
router := gin.Default()
router.StaticFile("/", "static/index.html")
api := router.Group("/api")
api.GET("/homepage", app.homePage)
err := router.Run(addr)
if err != nil {
panic(err)
log.Fatalf("Failed to start server: %v", err)
}
//http.Handle("/static/", http.StripPrefix("/static/", staticFileServer()))
//http.HandleFunc("/video/", app.serveVideo)
//http.HandleFunc("/stream/", app.serveStream)
//http.HandleFunc("/mark-watched/", app.handleMarkWatched)
//http.HandleFunc("/mark-unwatched/", app.handleMarkUnwatched)
//http.HandleFunc("/", app.serveIndex)
//
//err := http.ListenAndServe(addr, nil)
//if err != nil {
// panic(err)
//}
}
func (a *App) renderTemplate(w http.ResponseWriter, name string, viewmodel interface{}) {
err := renderTemplate(w, "index", viewmodel)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
type VideoModel struct {
ID int `json:"id"`
Thumbnail string `json:"thumbnail"`
}
func (a *App) getViewModelForVideo(id int) (*VideoInfoVM, error) {
// Query the database for the requested video
var title, description, thumbnail string
var watchState *string
err := a.db.Query(`SELECT title, description, thumbnail, watch_state FROM videos WHERE id = ? LIMIT 1`).Bind(id).ScanSingle(&title, &description, &thumbnail, &watchState)
if err != nil {
return nil, err
}
// Find the previous video ID based on upload date and episode number
var previousID int
err = a.db.Query(`
SELECT id FROM videos
WHERE (upload_date < (SELECT upload_date FROM videos WHERE id = ?))
OR (upload_date = (SELECT upload_date FROM videos WHERE id = ?) AND episode < (SELECT episode FROM videos WHERE id = ?))
ORDER BY upload_date DESC, episode DESC
LIMIT 1
`).Bind(id, id, id).ScanSingle(&previousID)
if err != nil {
// If there's no previous video, set previousID to 0 or -1 to indicate no previous video
previousID = 0
}
// Determine if the video has been watched
isWatched := watchState != nil && *watchState == "watched"
return &VideoInfoVM{
ID: id,
PreviousID: previousID,
Title: title,
Description: description,
Thumbnail: thumbnail,
IsWatched: isWatched,
}, nil
type HomePageModel struct {
CurrentVideo VideoModel `json:"currentVideo"`
}
func (a *App) getViewModelForUnwachtedVideo() (*VideoInfoVM, error) {
// Query the database for the oldest unwatched episode
var id int
err := a.db.Query(`SELECT id FROM videos WHERE (watch_state IS NULL OR watch_state != 'watched') ORDER BY upload_date, episode LIMIT 1`).ScanSingle(&id)
func (a *App) homePage(c *gin.Context) {
model := HomePageModel{}
err := a.db.Query("SELECT id, thumbnail FROM videos WHERE (watch_state IS NULL OR watch_state != 'watched') ORDER BY upload_date, episode LIMIT 1").
ScanSingle(&model.CurrentVideo.ID, &model.CurrentVideo.Thumbnail)
if err != nil {
return nil, err
log.Printf("Failed to fetch current video: %v", err)
c.JSON(500, gin.H{"error": "Failed to fetch current video"})
return
}
return a.getViewModelForVideo(id)
model.CurrentVideo.Thumbnail = "https://imgproxy.fourthwall.com/GHX1MSukwJHMQeiqcJLZL906v2--re7qQbQIlHgy5jY/rs:fill:607:342:0/q:90/sm:1/enc/NDJiMWM5YzU3ODJh/MzgzZXFIti10srar/EYcgeYXIe6MXrQge/VBPZVk3b6DCE53dq/VGponLkc45F9743G/4la9S4IjbcNxs4lF/WnLXCMzFhaSUaZnL/Og4de_FSYxQOtzCC/0pfkgH1g4FJfajde/KrZfes95EWXzg9sP/kvEwcqro2EM.webp"
c.JSON(200, model)
}
func (a *App) serveIndex(w http.ResponseWriter, r *http.Request) {
var vm *VideoInfoVM
var err error
// Check if a specific video ID was requested
videoIDParam := r.URL.Query().Get("video")
if videoIDParam != "" {
videoID, parseErr := strconv.Atoi(videoIDParam)
if parseErr == nil {
vm, err = a.getViewModelForVideo(videoID)
} else {
http.Error(w, "Invalid video ID", http.StatusBadRequest)
return
}
} else {
// Fall back to the default behavior - get the oldest unwatched video
vm, err = a.getViewModelForUnwachtedVideo()
}
if err != nil {
log.Printf("Failed to find video: %v", err)
http.Error(w, "Failed to find video", http.StatusInternalServerError)
return
}
a.renderTemplate(w, "index", vm)
}
func (a *App) serveVideo(w http.ResponseWriter, r *http.Request) {
// Parse the video ID from the URL
pathParts := strings.Split(r.URL.Path, "/")
if len(pathParts) < 3 {
http.Error(w, "Invalid video ID", http.StatusBadRequest)
return
}
videoIDStr := pathParts[2]
videoID, err := strconv.Atoi(videoIDStr)
if err != nil {
http.Error(w, "Invalid video ID", http.StatusBadRequest)
return
}
// Query the database for the video with the given ID
var title, description string
err = a.db.Query(`SELECT title, description FROM videos WHERE id = ?`).Bind(videoID).ScanSingle(&title, &description)
if err != nil {
log.Printf("Failed to find video: %v", err)
http.Error(w, "Video not found", http.StatusNotFound)
return
}
vm := VideoPlayerVM{
ID: videoID,
Title: title,
Description: description,
}
a.renderTemplate(w, "video", vm)
}
func (a *App) serveStream(w http.ResponseWriter, r *http.Request) {
// Parse the video ID from the URL
pathParts := strings.Split(r.URL.Path, "/")
if len(pathParts) < 3 {
http.Error(w, "Invalid video ID", http.StatusBadRequest)
return
}
videoIDStr := pathParts[2]
videoID, err := strconv.Atoi(videoIDStr)
if err != nil {
http.Error(w, "Invalid video ID", http.StatusBadRequest)
return
}
// Get video metadata from database
var year, episode int
err = a.db.Query(`SELECT year, episode FROM videos WHERE id = ?`).Bind(videoID).ScanSingle(&year, &episode)
if err != nil {
http.Error(w, "Video not found", http.StatusNotFound)
return
}
// Determine the video file path
downloadDir := os.Getenv("VIVAPLUS_DESTINATION")
if downloadDir == "" {
downloadDir = "./downloads"
}
seasonDir := filepath.Join(downloadDir, fmt.Sprintf("Season %d", year))
videoFilename := fmt.Sprintf("S%dE%03d.mp4", year, episode)
videoPath := filepath.Join(seasonDir, videoFilename)
// Check if the file exists
log.Printf("Streaming video: %s", videoPath)
_, err = os.Stat(videoPath)
if os.IsNotExist(err) {
http.Error(w, "Video file not found", http.StatusNotFound)
return
}
// Serve the file
http.ServeFile(w, r, videoPath)
}
func (a *App) handleMarkWatched(w http.ResponseWriter, r *http.Request) {
// Only handle POST requests
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
// Parse the video ID from the URL
pathParts := strings.Split(r.URL.Path, "/")
if len(pathParts) < 3 {
http.Error(w, "Invalid video ID", http.StatusBadRequest)
return
}
videoIDStr := pathParts[2]
videoID, err := strconv.Atoi(videoIDStr)
if err != nil {
http.Error(w, "Invalid video ID", http.StatusBadRequest)
return
}
// Update the watch state in the database
err = a.db.Query(`UPDATE videos SET watch_state = NULL WHERE id = ?`).Bind(videoID).Exec()
if err != nil {
http.Error(w, "Failed to update watch state", http.StatusInternalServerError)
return
}
h := a.htmx.NewHandler(w, r)
if h.RenderPartial() {
vm, err := a.getViewModelForVideo(videoID)
if err != nil {
http.Error(w, "Failed to find video", http.StatusInternalServerError)
return
}
a.renderTemplate(w, "frag-index", vm)
} else {
// Redirect back to the homepage
http.Redirect(w, r, "/", http.StatusSeeOther)
}
}
func (a *App) handleMarkUnwatched(w http.ResponseWriter, r *http.Request) {
// Only handle POST requests
if r.Method != http.MethodPost {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
// Parse the video ID from the URL
pathParts := strings.Split(r.URL.Path, "/")
if len(pathParts) < 3 {
http.Error(w, "Invalid video ID", http.StatusBadRequest)
return
}
videoIDStr := pathParts[2]
videoID, err := strconv.Atoi(videoIDStr)
if err != nil {
http.Error(w, "Invalid video ID", http.StatusBadRequest)
return
}
// Update the watch state in the database
err = a.db.Query(`UPDATE videos SET watch_state = 'unwatched' WHERE id = ?`).Bind(videoID).Exec()
if err != nil {
http.Error(w, "Failed to update watch state", http.StatusInternalServerError)
return
}
h := a.htmx.NewHandler(w, r)
if h.RenderPartial() {
vm, err := a.getViewModelForVideo(videoID)
if err != nil {
http.Error(w, "Failed to find video", http.StatusInternalServerError)
return
}
a.renderTemplate(w, "frag-index", vm)
} else {
// Redirect back to the homepage
http.Redirect(w, r, "/", http.StatusSeeOther)
}
}
//func (a *App) renderTemplate(w http.ResponseWriter, name string, viewmodel interface{}) {
// err := renderTemplate(w, "index", viewmodel)
// if err != nil {
// http.Error(w, err.Error(), http.StatusInternalServerError)
// }
//}
//
//func (a *App) getViewModelForVideo(id int) (*VideoInfoVM, error) {
// // Query the database for the requested video
// var title, description, thumbnail string
// var watchState *string
// err := a.db.Query(`SELECT title, description, thumbnail, watch_state FROM videos WHERE id = ? LIMIT 1`).Bind(id).ScanSingle(&title, &description, &thumbnail, &watchState)
// if err != nil {
// return nil, err
// }
//
// // Find the previous video ID based on upload date and episode number
// var previousID int
// err = a.db.Query(`
// SELECT id FROM videos
// WHERE (upload_date < (SELECT upload_date FROM videos WHERE id = ?))
// OR (upload_date = (SELECT upload_date FROM videos WHERE id = ?) AND episode < (SELECT episode FROM videos WHERE id = ?))
// ORDER BY upload_date DESC, episode DESC
// LIMIT 1
// `).Bind(id, id, id).ScanSingle(&previousID)
// if err != nil {
// // If there's no previous video, set previousID to 0 or -1 to indicate no previous video
// previousID = 0
// }
//
// // Determine if the video has been watched
// isWatched := watchState != nil && *watchState == "watched"
//
// return &VideoInfoVM{
// ID: id,
// PreviousID: previousID,
// Title: title,
// Description: description,
// Thumbnail: thumbnail,
// IsWatched: isWatched,
// }, nil
//}
//
//func (a *App) getViewModelForUnwachtedVideo() (*VideoInfoVM, error) {
// // Query the database for the oldest unwatched episode
// var id int
// err := a.db.Query(`SELECT id FROM videos WHERE (watch_state IS NULL OR watch_state != 'watched') ORDER BY upload_date, episode LIMIT 1`).ScanSingle(&id)
// if err != nil {
// return nil, err
// }
// return a.getViewModelForVideo(id)
//}
//
//func (a *App) serveIndex(w http.ResponseWriter, r *http.Request) {
// var vm *VideoInfoVM
// var err error
//
// // Check if a specific video ID was requested
// videoIDParam := r.URL.Query().Get("video")
// if videoIDParam != "" {
// videoID, parseErr := strconv.Atoi(videoIDParam)
// if parseErr == nil {
// vm, err = a.getViewModelForVideo(videoID)
// } else {
// http.Error(w, "Invalid video ID", http.StatusBadRequest)
// return
// }
// } else {
// // Fall back to the default behavior - get the oldest unwatched video
// vm, err = a.getViewModelForUnwachtedVideo()
// }
//
// if err != nil {
// log.Printf("Failed to find video: %v", err)
// http.Error(w, "Failed to find video", http.StatusInternalServerError)
// return
// }
// a.renderTemplate(w, "index", vm)
//}
//
//func (a *App) serveVideo(w http.ResponseWriter, r *http.Request) {
// // Parse the video ID from the URL
// pathParts := strings.Split(r.URL.Path, "/")
// if len(pathParts) < 3 {
// http.Error(w, "Invalid video ID", http.StatusBadRequest)
// return
// }
//
// videoIDStr := pathParts[2]
// videoID, err := strconv.Atoi(videoIDStr)
// if err != nil {
// http.Error(w, "Invalid video ID", http.StatusBadRequest)
// return
// }
//
// // Query the database for the video with the given ID
// var title, description string
// err = a.db.Query(`SELECT title, description FROM videos WHERE id = ?`).Bind(videoID).ScanSingle(&title, &description)
// if err != nil {
// log.Printf("Failed to find video: %v", err)
// http.Error(w, "Video not found", http.StatusNotFound)
// return
// }
//
// vm := VideoPlayerVM{
// ID: videoID,
// Title: title,
// Description: description,
// }
// a.renderTemplate(w, "video", vm)
//}
//
//func (a *App) serveStream(w http.ResponseWriter, r *http.Request) {
// // Parse the video ID from the URL
// pathParts := strings.Split(r.URL.Path, "/")
// if len(pathParts) < 3 {
// http.Error(w, "Invalid video ID", http.StatusBadRequest)
// return
// }
//
// videoIDStr := pathParts[2]
// videoID, err := strconv.Atoi(videoIDStr)
// if err != nil {
// http.Error(w, "Invalid video ID", http.StatusBadRequest)
// return
// }
//
// // Get video metadata from database
// var year, episode int
// err = a.db.Query(`SELECT year, episode FROM videos WHERE id = ?`).Bind(videoID).ScanSingle(&year, &episode)
// if err != nil {
// http.Error(w, "Video not found", http.StatusNotFound)
// return
// }
//
// // Determine the video file path
// downloadDir := os.Getenv("VIVAPLUS_DESTINATION")
// if downloadDir == "" {
// downloadDir = "./downloads"
// }
//
// seasonDir := filepath.Join(downloadDir, fmt.Sprintf("Season %d", year))
// videoFilename := fmt.Sprintf("S%dE%03d.mp4", year, episode)
// videoPath := filepath.Join(seasonDir, videoFilename)
//
// // Check if the file exists
// log.Printf("Streaming video: %s", videoPath)
// _, err = os.Stat(videoPath)
// if os.IsNotExist(err) {
// http.Error(w, "Video file not found", http.StatusNotFound)
// return
// }
//
// // Serve the file
// http.ServeFile(w, r, videoPath)
//}
//
//func (a *App) handleMarkWatched(w http.ResponseWriter, r *http.Request) {
// // Only handle POST requests
// if r.Method != http.MethodPost {
// http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
// return
// }
//
// // Parse the video ID from the URL
// pathParts := strings.Split(r.URL.Path, "/")
// if len(pathParts) < 3 {
// http.Error(w, "Invalid video ID", http.StatusBadRequest)
// return
// }
//
// videoIDStr := pathParts[2]
// videoID, err := strconv.Atoi(videoIDStr)
// if err != nil {
// http.Error(w, "Invalid video ID", http.StatusBadRequest)
// return
// }
//
// // Update the watch state in the database
// err = a.db.Query(`UPDATE videos SET watch_state = NULL WHERE id = ?`).Bind(videoID).Exec()
// if err != nil {
// http.Error(w, "Failed to update watch state", http.StatusInternalServerError)
// return
// }
//
// h := a.htmx.NewHandler(w, r)
// if h.RenderPartial() {
// vm, err := a.getViewModelForVideo(videoID)
// if err != nil {
// http.Error(w, "Failed to find video", http.StatusInternalServerError)
// return
// }
// a.renderTemplate(w, "frag-index", vm)
// } else {
// // Redirect back to the homepage
// http.Redirect(w, r, "/", http.StatusSeeOther)
// }
//}
//
//func (a *App) handleMarkUnwatched(w http.ResponseWriter, r *http.Request) {
// // Only handle POST requests
// if r.Method != http.MethodPost {
// http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
// return
// }
//
// // Parse the video ID from the URL
// pathParts := strings.Split(r.URL.Path, "/")
// if len(pathParts) < 3 {
// http.Error(w, "Invalid video ID", http.StatusBadRequest)
// return
// }
//
// videoIDStr := pathParts[2]
// videoID, err := strconv.Atoi(videoIDStr)
// if err != nil {
// http.Error(w, "Invalid video ID", http.StatusBadRequest)
// return
// }
//
// // Update the watch state in the database
// err = a.db.Query(`UPDATE videos SET watch_state = 'unwatched' WHERE id = ?`).Bind(videoID).Exec()
// if err != nil {
// http.Error(w, "Failed to update watch state", http.StatusInternalServerError)
// return
// }
//
// h := a.htmx.NewHandler(w, r)
// if h.RenderPartial() {
// vm, err := a.getViewModelForVideo(videoID)
// if err != nil {
// http.Error(w, "Failed to find video", http.StatusInternalServerError)
// return
// }
// a.renderTemplate(w, "frag-index", vm)
// } else {
// // Redirect back to the homepage
// http.Redirect(w, r, "/", http.StatusSeeOther)
// }
//}