mirror of
https://github.com/Yetangitu/owncloud-apps.git
synced 2025-10-02 14:49:17 +02:00
OPDS catalog: add Google Books API key (optional, increases rate limit when used)
This commit is contained in:
parent
0f7a2b145a
commit
e135c7ba14
5 changed files with 17 additions and 4 deletions
|
@ -26,6 +26,7 @@ $formats = array(
|
|||
$tmpl = new \OCP\Template('files_opds', 'admin');
|
||||
$tmpl->assign('feedSubtitle', Config::getApp('feed-subtitle', $l->t("%s OPDS catalog", $defaults->getName())));
|
||||
$tmpl->assign('isbndbKey', Config::getApp('isbndb-key', ''));
|
||||
$tmpl->assign('googleKey', Config::getApp('google-key', ''));
|
||||
$tmpl->assign('previewFormats', $formats);
|
||||
$tmpl->assign('cover-x', Config::getApp('cover-x', '200'));
|
||||
$tmpl->assign('cover-y', Config::getApp('cover-y', '200'));
|
||||
|
|
|
@ -26,6 +26,7 @@ if (isset($_POST['opdsCoverX'])) {
|
|||
$opdsThumbY = isset($_POST['opdsThumbY']) ? (int) $_POST['opdsThumbY'] : 36;
|
||||
$opdsFeedSubtitle = isset($_POST['opdsFeedSubtitle']) ? $_POST['opdsFeedSubtitle'] : $l->t("%s OPDS catalog", $defaults->getName());
|
||||
$opdsIsbndbKey = isset($_POST['opdsIsbndbKey']) ? $_POST['opdsIsbndbKey'] : '';
|
||||
$opdsGoogleKey = isset($_POST['opdsGoogleKey']) ? $_POST['opdsGoogleKey'] : '';
|
||||
|
||||
Config::setApp('cover-x', $opdsCoverX);
|
||||
Config::setApp('cover-y', $opdsCoverY);
|
||||
|
@ -33,6 +34,7 @@ if (isset($_POST['opdsCoverX'])) {
|
|||
Config::setApp('thumb-y', $opdsThumbX);
|
||||
Config::setApp('feed_subtitle', $opdsFeedSubtitle);
|
||||
Config::setApp('isbndb-key', $opdsIsbndbKey);
|
||||
Config::setApp('google-key', $opdsGoogleKey);
|
||||
} else {
|
||||
// set preview preferences
|
||||
$opdsPreviewEpub = $_POST['opdsPreviewEpub'];
|
||||
|
|
|
@ -28,7 +28,8 @@ $(document).ready(function(){
|
|||
opdsThumbX : $('#opds-thumb-x').val(),
|
||||
opdsThumbY : $('#opds-thumb-y').val(),
|
||||
opdsFeedSubtitle : $('#opds-feed-subtitle').val(),
|
||||
opdsIsbndbKey : $('#opds-isbndb-key').val()
|
||||
opdsIsbndbKey : $('#opds-isbndb-key').val(),
|
||||
opdsGoogleKey : $('#opds-google-key').val()
|
||||
};
|
||||
OC.msg.startSaving('#opds-admin .msg');
|
||||
$.post(OC.filePath('files_opds', 'ajax', 'admin.php'), data, opdsAdminCoverSettings.afterSave);
|
||||
|
@ -43,8 +44,8 @@ $(document).ready(function(){
|
|||
$('#opds-preview-opendocument').on("change", opdsAdminSettings.save);
|
||||
$('#opds-preview-msoffice').on("change", opdsAdminSettings.save);
|
||||
|
||||
$('#opds-cover-x,#opds-cover-y,#opds-thumb-x,#opds-thumb-y,#opds-feed-subtitle,#opds-isbndb-key').blur(opdsAdminCoverSettings.save);
|
||||
$('#opds-cover-x,#opds-cover-y,#opds-thumb-x,#opds-thumb-y,#opds-feed-subtitle,#opds-isbndb-key').keypress(function( event ) {
|
||||
$('#opds-cover-x,#opds-cover-y,#opds-thumb-x,#opds-thumb-y,#opds-feed-subtitle,#opds-isbndb-key,#opds-google-key').blur(opdsAdminCoverSettings.save);
|
||||
$('#opds-cover-x,#opds-cover-y,#opds-thumb-x,#opds-thumb-y,#opds-feed-subtitle,#opds-isbndb-key,#opds-google-key').keypress(function( event ) {
|
||||
if (event.which == 13) {
|
||||
event.preventDefault();
|
||||
opdsAdminCoverSettings.save();
|
||||
|
|
|
@ -25,7 +25,12 @@ class Google
|
|||
* @return int $status (0 on success, ERRORCODE otherwise)
|
||||
*/
|
||||
public static function get($isbn,&$meta) {
|
||||
$command = 'https://www.googleapis.com/books/v1/volumes?q=isbn:' . $isbn;
|
||||
$command = 'https://www.googleapis.com/books/v1/volumes?q=isbn:' . $isbn;
|
||||
if ($keyString = Config::getApp('google-key','')) {
|
||||
$keys = explode(',', $keyString);
|
||||
$key = $keys[rand(0,count($keys) - 1)];
|
||||
$command .= '&key=' . $key;
|
||||
}
|
||||
$data = json_decode(file_get_contents($command),true);
|
||||
if($data['totalItems'] > 0) {
|
||||
self::parse($data['items'][0]['volumeInfo'],$meta);
|
||||
|
|
|
@ -36,6 +36,10 @@ function checkBox($format) {
|
|||
<td><label for="opds-isbndb-key"><?php p($l->t('ISBNdb key:')) ?></label></td>
|
||||
<td><input type="text" id="opds-isbndb-key" title="<?php p($l->t("Enter ISBNdb key to use for metadata lookup. Leave blank to disable ISBNdb lookup.")); ?>" value="<?php p($_['isbndbKey']) ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="opds-google-key"><?php p($l->t('Google Books API key:')) ?></label></td>
|
||||
<td><input type="text" id="opds-google-key" title="<?php p($l->t("Enter Google Books API key to use for metadata lookup. Even though metadata lookup will work without an API key, the rate limit is higher when a key is used.")); ?>" value="<?php p($_['googleKey']) ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<p><?php p($l->t('Enable preview for:')); ?></p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue