ebook-server

command module
v0.0.0-...-64bad2c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2019 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

E-book server

I thought it was annoying to manually transfer e-book files from my computer/server to my Kobo eReader, so I wrote this to easily access and download them through the Kobo browser.
It's also my first project in Go!

When /api/ebooks/ is queried with the correct password:

  • looks for all epub files (this is the only format I've been using but this could easily be expanded upon) in the given "search" directories
  • checks if they already exist in the "storage" directory or not
  • copies over the non-existent files there
  • returns a json object of all the epub files in the "storage" directory, with various information (author, title, description) as extracted from the epub format

This info can be rendered as wished; I have a simple web page for displaying them in a table with a download link beside them.

When /api/ebook/:filename is queried with the correct password:

  • the relevant epub file is copied to a temporary file, accessible as a URL for the next 60 seconds
  • the temporary URL is returned

This isn't ideal since the temporary URL is publicly accessible. Originally I had the server return the actual binary epub file, downloadable as a blob, but I had a lot of trouble trying to get the Kobo to download blobs with the very limited JS support that its in-built browser has. This is why I've opted for this solution.

I haven't added any front-end code in this repo but I may do at a later date in the future! The password should be sent to the server through an x-password header. I realise now that there are built in basic HTTP frameworks for this, but this works at least :)

Some config before building:

  • If you don't want to use HTTPS: uncomment http.ListenAndServe and comment http.ListenAndServeTLS in main.go
  • Edit the config.toml file as necessary (remove Certificate and Key if not using HTTPS)
  • Place the config.toml file in the dir you run the executable from

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址