fix(opds): select proper opds search link (#2683)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { READEST_OPDS_USER_AGENT } from '@/services/constants';
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
async function handleRequest(request: NextRequest, method: 'GET' | 'HEAD') {
|
||||
@@ -35,7 +36,7 @@ async function handleRequest(request: NextRequest, method: 'GET' | 'HEAD') {
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 20000);
|
||||
const headers: HeadersInit = {
|
||||
'User-Agent': 'Readest/1.0 (OPDS Browser)',
|
||||
'User-Agent': READEST_OPDS_USER_AGENT,
|
||||
Accept: 'application/atom+xml, application/xml, text/xml, application/json, */*',
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ const POPULAR_CATALOGS: OPDSCatalog[] = [
|
||||
url: 'https://standardebooks.org/feeds/opds',
|
||||
description: 'Free and liberated ebooks, carefully produced for the true book lover',
|
||||
icon: '📚',
|
||||
disabled: isWebAppPlatform(),
|
||||
},
|
||||
{
|
||||
id: 'manybooks',
|
||||
|
||||
@@ -17,7 +17,13 @@ export function SearchView({ search, baseURL, onNavigate, resolveURL }: SearchVi
|
||||
const [formData, setFormData] = useState<Record<string, string>>(() => {
|
||||
const initial: Record<string, string> = {};
|
||||
search.params?.forEach((param) => {
|
||||
initial[param.name] = param.value || '';
|
||||
if (param.name === 'count') {
|
||||
initial[param.name] = '20';
|
||||
} else if (param.name === 'startPage') {
|
||||
initial[param.name] = '1';
|
||||
} else {
|
||||
initial[param.name] = param.value || '';
|
||||
}
|
||||
});
|
||||
return initial;
|
||||
});
|
||||
@@ -56,6 +62,8 @@ export function SearchView({ search, baseURL, onNavigate, resolveURL }: SearchVi
|
||||
publisher: _('Publisher'),
|
||||
language: _('Language'),
|
||||
subject: _('Subject'),
|
||||
count: _('Count'),
|
||||
startPage: _('Start Page'),
|
||||
};
|
||||
return labels[name] || name;
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@ import { getFileExtFromMimeType } from '@/libs/document';
|
||||
import { OPDSFeed, OPDSPublication, OPDSSearch } from '@/types/opds';
|
||||
import { isSearchLink, MIME, parseMediaType, resolveURL } from './utils/opdsUtils';
|
||||
import { getProxiedURL, fetchWithAuth, probeAuth, needsProxy } from './utils/opdsReq';
|
||||
import { READEST_OPDS_USER_AGENT } from '@/services/constants';
|
||||
import { FeedView } from './components/FeedView';
|
||||
import { PublicationView } from './components/PublicationView';
|
||||
import { SearchView } from './components/SearchView';
|
||||
@@ -362,7 +363,7 @@ export default function BrowserPage() {
|
||||
const useProxy = needsProxy(url);
|
||||
let downloadUrl = useProxy ? getProxiedURL(url, '', true) : url;
|
||||
const headers: Record<string, string> = {
|
||||
'User-Agent': 'Readest/1.0 (OPDS Browser)',
|
||||
'User-Agent': READEST_OPDS_USER_AGENT,
|
||||
};
|
||||
if (username || password) {
|
||||
const authHeader = await probeAuth(url, username, password, useProxy);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { md5 } from 'js-md5';
|
||||
import { isTauriAppPlatform, isWebAppPlatform } from '@/services/environment';
|
||||
import { fetch as tauriFetch } from '@tauri-apps/plugin-http';
|
||||
import { READEST_OPDS_USER_AGENT } from '@/services/constants';
|
||||
|
||||
/**
|
||||
* Extract username and password from URL credentials
|
||||
@@ -184,6 +185,7 @@ export const probeAuth = async (
|
||||
|
||||
const fetchURL = useProxy ? getProxiedURL(cleanUrl) : cleanUrl;
|
||||
const headers: Record<string, string> = {
|
||||
'User-Agent': READEST_OPDS_USER_AGENT,
|
||||
Accept: 'application/atom+xml, application/xml, text/xml',
|
||||
};
|
||||
|
||||
@@ -241,6 +243,7 @@ export const fetchWithAuth = async (
|
||||
|
||||
const fetchURL = useProxy ? getProxiedURL(cleanUrl) : cleanUrl;
|
||||
const headers: Record<string, string> = {
|
||||
'User-Agent': READEST_OPDS_USER_AGENT,
|
||||
Accept: 'application/atom+xml, application/xml, text/xml',
|
||||
...(options.headers as Record<string, string>),
|
||||
};
|
||||
|
||||
@@ -615,6 +615,8 @@ export const READEST_UPDATER_FILE = `${LATEST_DOWNLOAD_BASE_URL}/latest.json`;
|
||||
|
||||
export const READEST_CHANGELOG_FILE = `${LATEST_DOWNLOAD_BASE_URL}/release-notes.json`;
|
||||
|
||||
export const READEST_OPDS_USER_AGENT = 'Readest/1.0 (OPDS Browser)';
|
||||
|
||||
export const SYNC_PROGRESS_INTERVAL_SEC = 3;
|
||||
export const SYNC_NOTES_INTERVAL_SEC = 5;
|
||||
export const SYNC_BOOKS_INTERVAL_SEC = 5;
|
||||
|
||||
Reference in New Issue
Block a user