Convert Figma logo to code with AI

seblucas logocops

Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...)

1,422
229
1,422
101

Top Related Projects

3,846

Media server for comics/mangas/BDs/magazines/eBooks with API, OPDS and Kobo Sync support

19,281

The official source code repository for the calibre ebook manager

Lightweight YouTube client for Linux

Quick Overview

COPS (Calibre OPDS PHP Server) is a web-based e-book management system that allows users to access their Calibre library through a web browser or an OPDS-compatible e-reader. It provides a user-friendly interface for browsing, searching, and downloading e-books from a Calibre database without requiring the Calibre application to be running.

Pros

  • Easy to set up and use, especially for those already familiar with Calibre
  • Supports multiple e-book formats and OPDS protocol for compatibility with various e-readers
  • Lightweight and can run on low-powered devices like Raspberry Pi
  • Customizable interface with multiple themes and language support

Cons

  • Requires PHP and a web server, which may be challenging for some users to set up
  • Limited functionality compared to the full Calibre application
  • May have performance issues with very large libraries
  • Not actively maintained, with the last major update in 2019

Getting Started

  1. Ensure you have a web server with PHP 5.3+ installed.
  2. Download the latest COPS release from GitHub.
  3. Extract the files to your web server's document root.
  4. Copy config_local.php.example to config_local.php and edit it:
$config['calibre_directory'] = '/path/to/your/calibre/library';
$config['cops_title_default'] = "My COPS Server";
$config['cops_use_url_rewriting'] = "1";
  1. Access COPS through your web browser at http://your-server/cops/.

Competitor Comparisons

3,846

Media server for comics/mangas/BDs/magazines/eBooks with API, OPDS and Kobo Sync support

Pros of Komga

  • More active development with frequent updates and new features
  • Built-in user management and authentication system
  • Supports a wider range of comic book formats, including CBZ, CBR, and PDF

Cons of Komga

  • Requires Java runtime, which may be resource-intensive for some systems
  • Steeper learning curve for initial setup and configuration
  • Less focus on e-book formats compared to COPS

Code Comparison

COPS (PHP):

function getBookInfos($id) {
    $book = Book::getBookById($id);
    $data = array("id" => $id,
                  "title" => $book->title,
                  "author" => $book->getAuthorsName());
    return $data;
}

Komga (Kotlin):

fun getBookInfo(id: String): BookDto {
    val book = bookRepository.findByIdOrNull(id) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND)
    return BookDto.fromBook(book)
}

Both projects aim to provide digital library management, but Komga focuses more on comics and manga, while COPS is geared towards e-books. Komga offers a more modern, feature-rich experience with better comic support, while COPS is lighter and more suitable for e-book-centric libraries.

19,281

The official source code repository for the calibre ebook manager

Pros of Calibre

  • More comprehensive e-book management solution with a full GUI application
  • Supports a wider range of e-book formats and conversion capabilities
  • Larger and more active community, resulting in frequent updates and improvements

Cons of Calibre

  • Heavier resource usage due to its full-featured nature
  • More complex setup and configuration process
  • Steeper learning curve for new users

Code Comparison

Calibre (Python):

def get_cover(self, db, book_id):
    cover = db.cover(book_id, index_is_id=True)
    if cover:
        return cover
    return self.default_cover

COPS (PHP):

public function getBookCover($book) {
    $cover = $book->getCover();
    if ($cover) {
        return $cover;
    }
    return $this->getDefaultCover();
}

Both projects handle retrieving book covers, but Calibre's implementation is in Python, while COPS uses PHP. The overall structure is similar, with both checking for an existing cover before returning a default one.

Lightweight YouTube client for Linux

Pros of youtube-viewer

  • Focused on YouTube video browsing and playback
  • Supports various video quality options and formats
  • Includes search functionality and playlist management

Cons of youtube-viewer

  • Limited to YouTube content only
  • Requires additional dependencies for full functionality
  • May be affected by YouTube API changes

Code comparison

youtube-viewer:

sub get_video_info {
    my ($self, $video_id) = @_;
    my $url = $self->{_config}{YOUTUBE_API_BASE_URL} . "videos?part=snippet,contentDetails,statistics&id=$video_id&key=" . $self->{_config}{API_KEY};
    return $self->_make_api_request($url);
}

COPS:

public function getBookById($id) {
    $book = Book::getBookById($id, $this->db);
    if (is_null($book)) {
        throw new NotFoundHttpException();
    }
    return $book;
}

Key differences

  • youtube-viewer is written in Perl, while COPS is written in PHP
  • youtube-viewer focuses on video content, while COPS is designed for e-book management
  • youtube-viewer interacts with the YouTube API, while COPS works with a local database of e-books
  • COPS provides a web-based interface for e-book libraries, while youtube-viewer is primarily a command-line tool

Both projects serve different purposes and cater to distinct user needs. youtube-viewer is ideal for those who frequently interact with YouTube content, while COPS is better suited for managing personal e-book collections.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

COPS

COPS stands for Calibre OPDS (and HTML) Php Server.

See : COPS's home for more details.

Don't forget to check the Wiki.

Scrutinizer Code Quality

Code Coverage

Build Status / Scrutinizer

Build Status

Selenium Test Status

Why ?

In my opinion Calibre is a marvelous tool but is too big and has too much dependencies to be used for its content server.

That's the main reason why I coded this OPDS server. I needed a simple tool to be installed on a small server (Seagate Dockstar in my case).

I initially thought of Calibre2OPDS but as it generate static file no search was possible.

Later I added an simple HTML catalog that should be usable on my Kobo.

So COPS's main advantages are :

  • No need for many dependencies.
  • No need for a lot of CPU or RAM.
  • Not much code.
  • Search is available.
  • It was fun to code.

If you want to use the OPDS feed don't forget to specify feed.php at the end of your URL.

You just have to sync your Calibre directory to your COPS server the way you prefer (Dropbox, Bt Sync, Syncthing, use a directory shared with Nextcloud, ...).

Prerequisites

  1. PHP 5.3, 5.4, 5.5, 5.6, 7.X or hhvm with GD image processing, Libxml, Intl, Json & SQLite3 support (PHP 5.6 or later recommended).
  2. A web server with PHP support. I tested with various version of Nginx and Apache. Other people reported it working with Apache and Cherokee. You can also use PHP embedded server (https://github.com/seblucas/cops/wiki/Howto---PhpEmbeddedServer)
  3. The path to a calibre library (metadata.db, format, & cover files).

On any Debian based Linux you can use : apt-get install php5-gd php5-sqlite php5-json php5-intl

If you use Debian Stretch : apt-get install php7.0-gd php7.0-sqlite3 php7.0-json php7.0-intl php7.0-xml php7.0-mbstring php7.0-zip

On Centos you may have to add : yum install php-xml

Install a release (Easiest way)

  1. Extract the zip file you got from the release page to a folder in web space (visible to the web server).
  2. If you're doing a first-time install, copy config_local.php.example to config_local.php
  3. Edit config_local.php to match your config.
  4. If needed add other configuration item from config_default.php

If you like Docker, you can also try this multiarch docker container from linuxserver.io It has builds for x64, armhf and arm64.

Install from sources

git clone https://github.com/seblucas/cops.git # or download lastest zip see below
cd cops
wget https://getcomposer.org/composer.phar
php composer.phar global require "fxp/composer-asset-plugin:~1.1"
php composer.phar install --no-dev --optimize-autoloader

After that you can use the previous how-to starting at the second step.

Note that instead of cloning you can also get latest master as zip

Note that if your PHP version is lower that 5.6, then you may have to remove composer.lock before starting the last line.

Where to put my Calibre directory ?

Long story short : ALWAYS outside of COPS's directory especially if COPS is installed on a VPS / Server. If you follow my advice then your data will be safe.

If you choose to put your Calibre directory inside your web directory and use Nginx then you will have to edit /etc/nginx/mime.types to add these lines :

application/epub+zip epub;
application/x-mobipocket-ebook mobi prc azw;

Known problems

Not a lot, except for the bad quality of the code (first PHP project ever) ;)

Please see https://github.com/seblucas/cops/issues for open issues

Need help

Please read https://github.com/seblucas/cops/wiki and check the FAQ.

Contributing

As you could see here, I appreciate every contributions and there were a lot over time. So don't be shy and submit your Pull Requests.

Note to translators : please prefer using Transifex instead of doing a PR.

I only have one limit (I may have more but that one is the worse) : COPS' goal is to provide an alternative to Calibre's content server and not to replace Calibre entirely. So I will refuse any PR making changes to the database content.

Credits

External libraries used :

Copyright & License

COPS - 2012-2019 (c) Sébastien Lucas

See COPYING and file headers for license info