simjanos-dev / LinguaCafe

LinguaCafe is a self-hosted software that helps language learners read foreign languages.
https://simjanos-dev.github.io/LinguaCafeHome/
GNU General Public License v3.0
889 stars 32 forks source link

Add support for OPDS import #171

Open aero31aero opened 8 months ago

aero31aero commented 8 months ago

Hi, I'd like to propose adding OPDS import. In case you're unfamiliar with OPDS, its an XML based API for browsing library catalogues that makes it very simple to download books. You can read the full spec here but I'll show a dummy session below:

I run a calibre-web instance for my books, which exposes an api like:

$ curl https://calibre.example.com/opds/ # opds home-page
$ curl https://calibre.example.com/opds/language # lists the languages of books available
$ curl https://calibre.example.com/opds/language/3 # this happens to be my target lang and this page shows all my books in my target lang.

Any specific entry looks like this:

<entry>                                                                                                                                                                                                                                   
    <title>나태주동시집</title>                                                                                                                                                                                                             
    <id>urn:uuid:f89fc892-82a8-4bb9-8406-fa19deda93b9</id>                                                                                                                                                                                  
    <updated>2023-08-05T00:17:44+00:00</updated>                                                                                                                                              
      <author>                                                                                                                                                                                                                              
        <name>나태주 창작 동시집 (나태주) (Z-Library)</name>                                                                                                                                                                                
      </author>                                                                                                                                                                                                                    
    <published>2020-11-17T18:30:00+00:00</published>                                                                                                                                                                                                                                                                                                                                                                                    
      <dcterms:language>kor</dcterms:language>                                                                                                                                                                                                                                                                                                                                                                                                
    <link type="image/jpeg" href="/opds/cover/125" rel="http://opds-spec.org/image"/>                                                                                                                                                       
    <link type="image/jpeg" href="/opds/cover/125" rel="http://opds-spec.org/image/thumbnail"/>                                                                                                                                             

    <link rel="http://opds-spec.org/acquisition" href="/opds/download/125/epub/"                                                                                                                                                            
          length="47908934" mtime="2023-08-05T00:17:44+00:00" type="application/epub+zip"/>                                                                                                                                                 

  </entry>

This would make importing books trivial (instead of downloading them locally and then uploading them), or also allow you to set up auto-import rules such that you set a language and all books in your catalog in that language get imported.

simjanos-dev commented 8 months ago

Hi!

This is a great idea! A lot of e-book platform support OPDS.

It will take a while for me to get to it, but I will definitely add support for this.

simjanos-dev commented 8 months ago

or also allow you to set up auto-import rules such that you set a language and all books in your catalog in that language get imported

I'll have to add this to the user manual. It's better to not import text that you don't intend to read, because whenever you create a phrase, it will be indexed in every text you have imported.

Not sure at what point will this become an issue, I have 700+ phrases and 6~ books imported, and it is still functioning well.