mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 09:32:24 -04:00
Fix OPDS feed wrong links
This commit is contained in:
parent
7c9015f620
commit
8a1d31be2a
1 changed files with 9 additions and 7 deletions
|
@ -17,9 +17,10 @@ foreach($contentFiles as $path){
|
||||||
$xml->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/');
|
$xml->registerXPathNamespace('dc', 'http://purl.org/dc/elements/1.1/');
|
||||||
|
|
||||||
$updated = $xml->xpath('/package/metadata/meta[@property="dcterms:modified"]') ?: [];
|
$updated = $xml->xpath('/package/metadata/meta[@property="dcterms:modified"]') ?: [];
|
||||||
|
$identifier = $xml->xpath('/package/metadata/dc:identifier') ?: [];
|
||||||
|
|
||||||
if($updated !== false && sizeof($updated) > 0){
|
if(sizeof($identifier) > 0 && sizeof($updated) > 0){
|
||||||
$sortedContentFiles[(string)$updated[0]] = $xml;
|
$sortedContentFiles[(string)$updated[0] . ' ' . $identifier[0]] = $xml;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +55,9 @@ print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
||||||
|
|
||||||
$authors = array();
|
$authors = array();
|
||||||
$temp = $xml->xpath('/package/metadata/dc:identifier') ?: [];
|
$temp = $xml->xpath('/package/metadata/dc:identifier') ?: [];
|
||||||
$url = preg_replace('/^url:/ius', '', (string)array_shift($temp)) ?? '';
|
$identifier = (string)array_shift($temp);
|
||||||
$url = preg_replace('/^https:\/\/standardebooks.org/ius', $webUrl, $url) ?? '';
|
$url = preg_replace('/^url:/ius', '', $identifier) ?? '';
|
||||||
|
$url = preg_replace('/^https:\/\/standardebooks\.org/ius', $webUrl, $url) ?? '';
|
||||||
$relativeUrl = preg_replace('/^' . preg_quote($webUrl, '/') . '/ius', '', $url) ?? '';
|
$relativeUrl = preg_replace('/^' . preg_quote($webUrl, '/') . '/ius', '', $url) ?? '';
|
||||||
|
|
||||||
$temp = $xml->xpath('/package/metadata/dc:title') ?: [];
|
$temp = $xml->xpath('/package/metadata/dc:title') ?: [];
|
||||||
|
@ -84,9 +86,9 @@ print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
||||||
|
|
||||||
$filesystemPath = preg_replace('/\/src\/epub\/content.opf$/ius', '', $path) ?? '';
|
$filesystemPath = preg_replace('/\/src\/epub\/content.opf$/ius', '', $path) ?? '';
|
||||||
$temp = glob($filesystemPath . '/dist/*.epub');
|
$temp = glob($filesystemPath . '/dist/*.epub');
|
||||||
$epubFilename = preg_replace('/(\|\.epub)/ius', '', preg_replace('/.+\//ius', '', array_shift($temp) ?? '') ?? '') ?? '';
|
$filename = preg_replace('/^url:https:\/\/standardebooks\.org\/ebooks\//ius', '', $identifier);
|
||||||
$temp = glob($filesystemPath . '/dist/*.azw3');
|
$epubFilename = str_replace('/', '_', $filename) . '.epub';
|
||||||
$kindleFilename = preg_replace('/.+\//ius', '', array_shift($temp) ?? '') ?? '';
|
$kindleFilename = str_replace('/', '_', $filename) . '.azw3';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<entry>
|
<entry>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue