Warning
Project made for personal use, use at your own risk
This is a server written in go for me to watch anime. What are the requisites?
- All video files are inside a folder
- The modified time of the files is the order in which I'll watch
- After watching I want to choose whether to keep, like or just mark as watched
- If I choose not to keep a file, it'll be truncated (for me to remember not to download twice)
- I want to be able to watch again files I keep
- The database needs to be updated with the videos in the folder
- endpoints
- next in queue
/next-video
- list saved
/video-list
- watch saved
/watch/{id}
- serve video file
/video/{id}
- read folder to update database
/update
- create home page with statistics
/
- next in queue
- respect parameters
- truncate files
- refactoring
- make ini the same name as executable
- automatically create ini file when it doesn't exist
I made this project first using svelte (version 4) + Bun, but the start time is eye boggling long (above 20s). So I used this opportunity to put my go skills into practice and try solving this minor inconvenience.
- Download and install go version 1.23.1 (or make it work on other version on your own)
- Install Templ
- Generate templates
templ generate
- Build the project
go build -o bin/
- Create an
go-video-viewer.ini
file in the/bin
folder (ini file must have the same name as the executable)database= # database path video_folder= # video folder path
- Run the executable
The ini file can have the following properties:
property | description |
---|---|
database | The database file path. Ex: database=videos.db , database=C:\Program Files\go-video-viewer\database.db |
video_folder | The path of the video folder. Ex: video_folder=C:\Users\me\Videos , video_folder=videos |
address | (OPTIONAL) The address used to run the server (default on 127.0.0.1). Ex: localhost , 127.0.0.1 |
port | (OPTIONAL) The port used to run the server (default on 3000). Ex: 8000 , 8080 , 16217 |
In the previous version of this project, the "database" was a JSON file with the following schema:
{
"watched": [
{
"name": "file name + extension",
"date": "some ISO format date",
"favorited": true, // omitted if false
"save": true // ommitted if false
},
...
],
"toWatch": [
{
"name": "file name + extension",
"date": "some ISO format date",
"favorited": true, // omitted if false
"save": true // ommitted if false
},
...
],
"current": {
"name": "file name + extension",
"date": "some ISO format date",
"favorited": true, // omitted if false
"save": true // ommitted if false
}
}
So to import this data into this project you can inform the command line argument json-file
, using it like this:
.\go-video-viewer.exe --json-file "path to the json file"