This repository has been archived by the owner on Aug 18, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add support of TINAMI [TINAMI](https://tinami.com) is one of famous Japanese illustration community for fans of anime and comics like Pixiv. * fix some bad JavaScript and modify an image URL to use HTTPS
- Loading branch information
Showing
4 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import convert from 'xml-js'; | ||
|
||
export default function ($) { | ||
return { | ||
name: 'TINAMI', | ||
setting: 'tinami', | ||
re: /(?:www.tinami.com\/view|tinami.jp\/)/, | ||
default: true, | ||
callback: url => { | ||
let imageId = new URL(url).pathname.split('/').pop(); | ||
// If short url, encode ID with base 36 | ||
if (url.includes('tinami.jp')) { | ||
imageId = parseInt(imageId, 36); | ||
} | ||
return fetch($.getSafeURL( | ||
`${$.getEnpointFor('tinami')}cont_id=${imageId}&api_key=${$.getKeyFor('tinami')}`)) | ||
.then($.statusAndText) | ||
.then(xml => convert.xml2js(xml, {compact: true})) | ||
.then(json => { | ||
// Quit if there is non-public image or no image | ||
if (json.rsp._attributes.stat !== 'ok' || | ||
json.rsp.content._attributes.type == 'novel') { | ||
return; | ||
} | ||
const image = json.rsp.content.image || | ||
json.rsp.content.images.image[0] || | ||
json.rsp.content.images.image; | ||
const imgUrl = $.getSafeURL(image.url._text.replace( | ||
'http://api.tinami.com/', 'https://www.tinami.com/api/')); | ||
return Promise.resolve({ | ||
type: 'image', | ||
thumbnail_url: imgUrl, | ||
url: imgUrl, | ||
}); | ||
}); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters