### Get Book Source List via Web Service Source: https://context7.com/mgz0227/legado-harmony/llms.txt Fetch a list of all configured book sources using a GET request to the Legado web service. This is useful for managing or displaying available sources. ```bash # Get book source list curl -X GET "http://192.168.1.100:1122/getBookSources" ``` -------------------------------- ### Get Current Bookshelf via Web Service Source: https://context7.com/mgz0227/legado-harmony/llms.txt Retrieve the current list of books in the user's bookshelf using a GET request to the Legado web service. The device IP and port must be known. ```bash # The web service runs on a configurable port (default typically 1122) # Base URL format: http://{device-ip}:{port} # Get current bookshelf curl -X GET "http://192.168.1.100:1122/getBookshelf" ``` -------------------------------- ### Get Book Content via Web Service API Source: https://context7.com/mgz0227/legado-harmony/llms.txt Fetch the content of a specific chapter using its URL. This is useful for reading the actual text of a chapter. ```bash curl -X GET "http://192.168.1.100:1122/getBookContent?url=https://novel.example.com/chapter/456" ``` -------------------------------- ### Get Book Chapters via Web Service API Source: https://context7.com/mgz0227/legado-harmony/llms.txt Retrieve the table of contents or chapter list for a given book URL. Ensure the URL is correctly encoded. ```bash curl -X GET "http://192.168.1.100:1122/getChapterList?url=https://novel.example.com/book/123" ``` -------------------------------- ### Book Source Rule Structure Example Source: https://context7.com/mgz0227/legado-harmony/llms.txt This JSON object defines the parsing rules for a specific book source, including search, explore, book info, table of contents, and content extraction. ```json { "bookSourceName": "Novel Website", "bookSourceUrl": "https://novel.example.com", "bookSourceType": 0, "bookSourceGroup": "Chinese Novels", "enabled": true, "enabledExplore": true, "header": "{\"User-Agent\": \"Mozilla/5.0\"}", "loginUrl": "", "bookUrlPattern": "", "searchUrl": "/search.php?keyword={{key}}&page={{page}}", "ruleSearch": { "bookList": ".search-result-list .book-item", "name": ".book-name@text", "author": ".book-author@text", "intro": ".book-intro@text", "coverUrl": ".book-cover img@src", "bookUrl": "a.book-link@href" }, "exploreUrl": "[{\"title\":\"Hot\",\"url\":\"/hot/{{page}}.html\"},{\"title\":\"New\",\"url\":\"/new/{{page}}.html\"}]", "ruleExplore": { "bookList": ".book-list .item", "name": "h3@text", "author": ".author@text", "coverUrl": "img@data-src", "bookUrl": "a@href" }, "ruleBookInfo": { "name": "h1.book-title@text", "author": ".book-author a@text", "intro": ".book-intro@html", "coverUrl": ".book-cover img@src", "tocUrl": "//a[contains(text(),'目录')]/@href" }, "ruleToc": { "chapterList": ".chapter-list li", "chapterName": "a@text", "chapterUrl": "a@href" }, "ruleContent": { "content": "#chapter-content@html", "nextContentUrl": "a.next-page@href", "replaceRegex": "广告.*?内容" } } ``` -------------------------------- ### Import Theme Configuration via URL Source: https://context7.com/mgz0227/legado-harmony/llms.txt Apply custom themes by importing a JSON configuration file via URL. This allows for easy customization of the application's appearance. ```bash legado://import/theme?src=https://example.com/dark-theme.json ``` ```json { "themeName": "Night Reader", "bgColor": "#1a1a1a", "textColor": "#e0e0e0", "accentColor": "#4a90d9" } ``` -------------------------------- ### Import Reading Layout Configuration via URL Source: https://context7.com/mgz0227/legado-harmony/llms.txt Customize the reading interface by importing layout configurations via URL. This includes settings like font size, line spacing, and page mode. ```bash legado://import/readConfig?src=https://example.com/reading-config.json ``` ```json { "fontSize": 18, "lineSpacing": 1.5, "paragraphSpacing": 2.0, "fontFamily": "serif", "pageMode": "scroll", "boldText": false } ``` -------------------------------- ### Import RSS/Subscription Source via URL Source: https://context7.com/mgz0227/legado-harmony/llms.txt Import RSS or subscription sources by providing a URL to a JSON configuration file. The structure should match the expected RSS source format. ```bash legado://import/rssSource?src=https://example.com/rss-source.json ``` ```json { "sourceName": "Tech News", "sourceUrl": "https://news.example.com", "sourceGroup": "Technology", "ruleArticles": ".article-list .item", "ruleTitle": ".headline@text", "ruleLink": "a@href" } ``` -------------------------------- ### Import Book Source via URL Source: https://context7.com/mgz0227/legado-harmony/llms.txt Use this URL scheme to import a book source from a remote JSON file. Ensure the JSON structure adheres to Legado's book source format. ```bash legado://import/bookSource?src=https://example.com/sources/mysource.json ``` ```json { "bookSourceName": "Example Source", "bookSourceUrl": "https://example.com", "bookSourceType": 0, "bookSourceGroup": "Novel", "searchUrl": "/search?q={{key}}", "ruleSearch": { "bookList": ".book-item", "name": ".title@text", "author": ".author@text", "bookUrl": "a@href" } } ``` -------------------------------- ### Add Book to Bookshelf via URL Source: https://context7.com/mgz0227/legado-harmony/llms.txt Directly add a book to the user's bookshelf by providing its information through a URL. This requires a JSON object containing details like name, author, and book URL. ```bash legado://import/addToBookshelf?src=https://example.com/book-info.json ``` ```json { "name": "Sample Novel", "author": "Author Name", "bookUrl": "https://novel.example.com/book/123", "coverUrl": "https://novel.example.com/covers/123.jpg", "intro": "A captivating story about..." } ``` -------------------------------- ### Import TTS/HTTP Audio Engine via URL Source: https://context7.com/mgz0227/legado-harmony/llms.txt Configure online text-to-speech (TTS) engines by importing their configurations via URL. This enables text-to-speech functionality within the app. ```bash legado://import/httpTTS?src=https://example.com/tts-config.json ``` ```json { "name": "Custom TTS", "url": "https://tts.example.com/api/speak?text={{text}}&voice={{voice}}", "contentType": "audio/mp3" } ``` -------------------------------- ### Import Dictionary Rules via URL Source: https://context7.com/mgz0227/legado-harmony/llms.txt Import rules for dictionary lookups using a URL pointing to a JSON configuration file. This feature enhances the reading experience by providing quick access to definitions. ```bash legado://import/dictRule?src=https://example.com/dict-rules.json ``` -------------------------------- ### Search for Books via Web Service API Source: https://context7.com/mgz0227/legado-harmony/llms.txt Use this endpoint to search for books across different sources. Replace 'fantasy%20novel' with your search query. ```bash curl -X GET "http://192.168.1.100:1122/searchBook?key=fantasy%20novel" ``` -------------------------------- ### Query Book Sources using HarmonyOS DataAbility Source: https://context7.com/mgz0227/legado-harmony/llms.txt Retrieve a list of enabled book sources with their names and URLs using the HarmonyOS DataAbility. Predicates can be used to sort the results. ```typescript async function queryBookSources() { const uri = `dataability:///${LEGADO_AUTHORITY}/bookSource`; const predicates = new dataAbility.DataAbilityPredicates(); predicates.orderByAsc("bookSourceName"); return await dataAbility.query(uri, ["bookSourceName", "bookSourceUrl", "enabled"], predicates); } ``` -------------------------------- ### Query Bookshelf Data using HarmonyOS DataAbility Source: https://context7.com/mgz0227/legado-harmony/llms.txt Access and retrieve data from the user's bookshelf using the HarmonyOS DataAbility. This requires proper import and URI formatting. ```typescript import dataAbility from '@ohos.data.dataAbility'; // Content URI format for Legado data access const LEGADO_AUTHORITY = "com.legado.app.provider"; // Query bookshelf data async function queryBookshelf() { const uri = `dataability:///${LEGADO_AUTHORITY}/bookshelf`; const predicates = new dataAbility.DataAbilityPredicates(); const resultSet = await dataAbility.query(uri, null, predicates); const books = []; while (resultSet.goToNextRow()) { books.push({ name: resultSet.getString(resultSet.getColumnIndex("name")), author: resultSet.getString(resultSet.getColumnIndex("author")), lastReadTime: resultSet.getLong(resultSet.getColumnIndex("lastReadTime")) }); } return books; } ``` -------------------------------- ### Save/Import Book Sources via Web Service Source: https://context7.com/mgz0227/legado-harmony/llms.txt Save or import new book sources by sending a POST request to the Legado web service with a JSON payload containing the source details. The 'Content-Type' header must be set to 'application/json'. ```bash # Save/import book sources curl -X POST "http://192.168.1.100:1122/saveBookSource" \ -H "Content-Type: application/json" \ -d '[{"bookSourceName":"Test","bookSourceUrl":"https://test.com"}]' ``` -------------------------------- ### Import TXT Table of Contents Rules via URL Source: https://context7.com/mgz0227/legado-harmony/llms.txt Import rules for parsing the table of contents (TOC) from local TXT files. This is useful for organizing chapters in text-based novels. ```bash legado://import/textTocRule?src=https://example.com/toc-rules.json ``` ```json { "name": "Standard Chapters", "rule": "^第[0-9一二三四五六七八九十百千]+章", "isRegex": true } ``` -------------------------------- ### Import Text Replacement Rules via URL Source: https://context7.com/mgz0227/legado-harmony/llms.txt Import rules for text replacement, often used for ad removal, using a URL pointing to a JSON configuration. The 'isRegex' field indicates if the pattern is a regular expression. ```bash legado://import/replaceRule?src=https://example.com/replace-rules.json ``` ```json { "name": "Remove Ads", "pattern": "广告内容.*?结束", "replacement": "", "isRegex": true, "scope": "content" } ``` -------------------------------- ### Web Service API Source: https://context7.com/mgz0227/legado-harmony/llms.txt Legado provides a built-in web service that exposes a REST API for managing the application remotely. When enabled, external applications can interact with the bookshelf, book sources, and reading progress through HTTP requests. ```APIDOC ## Web Service API Legado provides a built-in web service that exposes a REST API for managing the application remotely. When enabled, external applications can interact with the bookshelf, book sources, and reading progress through HTTP requests. Base URL Format: `http://{device-ip}:{port}` (default port typically 1122) ### Get Current Bookshelf **Description**: Retrieves the current list of books in the user's bookshelf. **Method**: GET **Endpoint**: `/getBookshelf` **Example**: `curl -X GET "http://192.168.1.100:1122/getBookshelf"` ### Get Book Source List **Description**: Retrieves the list of configured book sources. **Method**: GET **Endpoint**: `/getBookSources` **Example**: `curl -X GET "http://192.168.1.100:1122/getBookSources"` ### Save/Import Book Sources **Description**: Saves or imports book sources. Accepts an array of book source objects. **Method**: POST **Endpoint**: `/saveBookSource` **Parameters**: #### Request Body - **bookSourceName** (string) - Required - The name of the book source. - **bookSourceUrl** (string) - Required - The URL of the book source. **Example**: `curl -X POST "http://192.168.1.100:1122/saveBookSource" \ -H "Content-Type: application/json" \ -d '[{"bookSourceName":"Test","bookSourceUrl":"https://test.com"}]'` ``` -------------------------------- ### URL Import API Source: https://context7.com/mgz0227/legado-harmony/llms.txt The URL import API allows external applications to trigger one-click imports of various content types into Legado using a custom URL scheme. ```APIDOC ## URL Import API The URL import API allows external applications to trigger one-click imports of various content types into Legado using a custom URL scheme. This enables seamless integration with web browsers and other apps for importing book sources, RSS sources, themes, and more. Base URL Scheme: `legado://import/{path}?src={url}` ### Import Book Source **Description**: Import a book source from a remote URL. **Method**: GET (via URL scheme) **Endpoint**: `legado://import/bookSource?src={url}` **Parameters**: #### Query Parameters - **src** (string) - Required - The URL to the book source JSON file. ### Import RSS/Subscription Source **Description**: Import an RSS subscription source from a remote URL. **Method**: GET (via URL scheme) **Endpoint**: `legado://import/rssSource?src={url}` **Parameters**: #### Query Parameters - **src** (string) - Required - The URL to the RSS source JSON file. ### Import Replacement Rules **Description**: Import text replacement rules for ad removal. **Method**: GET (via URL scheme) **Endpoint**: `legado://import/replaceRule?src={url}` **Parameters**: #### Query Parameters - **src** (string) - Required - The URL to the replacement rules JSON file. ### Import Theme Configuration **Description**: Import a custom theme configuration. **Method**: GET (via URL scheme) **Endpoint**: `legado://import/theme?src={url}` **Parameters**: #### Query Parameters - **src** (string) - Required - The URL to the theme JSON file. ### Import Reading Layout Configuration **Description**: Import reading layout configuration. **Method**: GET (via URL scheme) **Endpoint**: `legado://import/readConfig?src={url}` **Parameters**: #### Query Parameters - **src** (string) - Required - The URL to the reading configuration JSON file. ### Import TXT Table of Contents Rules **Description**: Import local TXT novel TOC parsing rules. **Method**: GET (via URL scheme) **Endpoint**: `legado://import/textTocRule?src={url}` **Parameters**: #### Query Parameters - **src** (string) - Required - The URL to the TOC rules JSON file. ### Import TTS/HTTP Audio Engine **Description**: Import online text-to-speech engine configuration. **Method**: GET (via URL scheme) **Endpoint**: `legado://import/httpTTS?src={url}` **Parameters**: #### Query Parameters - **src** (string) - Required - The URL to the TTS engine configuration JSON file. ### Import Dictionary Rules **Description**: Import dictionary lookup rules. **Method**: GET (via URL scheme) **Endpoint**: `legado://import/dictRule?src={url}` **Parameters**: #### Query Parameters - **src** (string) - Required - The URL to the dictionary rules JSON file. ### Add Book to Bookshelf **Description**: Add a book directly to the bookshelf. **Method**: GET (via URL scheme) **Endpoint**: `legado://import/addToBookshelf?src={url}` **Parameters**: #### Query Parameters - **src** (string) - Required - The URL to the book information JSON file. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.