diff --git a/index.js b/index.js index fa6e228..3f5e762 100644 --- a/index.js +++ b/index.js @@ -10,6 +10,7 @@ import { getMalojaScrobble, getMastodonPost, getRSSItemTitle, + getSomePicsPost, getSourceTubeActivity, getSteamRecentlyPlayed, getTraktEpisode, @@ -23,6 +24,7 @@ const feedHandlers = { rss: getRSSItemTitle, atom: getAtomFeed, json: getJsonFeedItemTitle, + 'some.pics': getSomePicsPost, 'source.tube': getSourceTubeActivity, mastodon: getMastodonPost, letterboxd: getLetterboxdActivity, @@ -79,9 +81,13 @@ export default async function now() { } // generic handlers expect just feedUrl string, special handlers expect config object - const handlerParam = ['rss', 'atom', 'json', 'maloja'].includes( - item.feedType, - ) + const handlerParam = [ + 'rss', + 'atom', + 'json', + 'maloja', + 'some.pics', + ].includes(item.feedType) ? feedUrl : { ...item, feedUrl } const latest = await handler(handlerParam) diff --git a/now-page-template.md b/now-page-template.md index 9ae62fe..6e7db73 100644 --- a/now-page-template.md +++ b/now-page-template.md @@ -6,49 +6,58 @@ I listened to this
lastfm -
+
I watched this episode
trakt-episode
- +
-
+
I watched this movie
trakt-movie
- +
-
+
I rated this
letterboxd
-
+
I'm reading this
hardcover
-
+
I played this
steam
-
+
I shared this photo
some.pics
-
+
I wrote this
weblog @@ -62,18 +71,33 @@
{last-updated}
-

Want your own automatically updated Now page? Check out now-updater.

+

Want your own automatically updated Now page? Check out now-updater.


- People Pledge 88x31 Badge - Follow me on Mastodon - @dylan@social.lol 88x31 Badge - Badly Hand-Coded and Proud 88x31 Badge - omg.lol 88x31 Badge - Anna's Archive 88x31 Badge - Internet Privacy 88x31 Badge - omg.lol 88x31 Badge + People Pledge 88x31 Badge + Follow me on Mastodon - @dylan@social.lol 88x31 Badge + Badly Hand-Coded and Proud 88x31 Badge + omg.lol 88x31 Badge + Anna's Archive 88x31 Badge + Internet Privacy 88x31 Badge + omg.lol 88x31 Badge
-

Back to my omg.lol page!

+

Back to my omg.lol page!

\ No newline at end of file diff --git a/services.js b/services.js index 22cb984..f74146d 100644 --- a/services.js +++ b/services.js @@ -17,7 +17,7 @@ export const services = [ isActive: true, userId: 'dylan', // your omg.lol username feedUrlTemplate: 'https://{userId}.some.pics/rss', - feedType: 'rss', + feedType: 'some.pics', }, // ======================================================================== diff --git a/utils.js b/utils.js index d12d1e8..4d02a71 100644 --- a/utils.js +++ b/utils.js @@ -87,6 +87,27 @@ export async function getJsonFeedItemTitle(feedUrl, showImage = true) { return { text: title, url, image: showImage ? image : null } } +// ======================================================================== +// omg.lol services +// ======================================================================== + +// some.pics rss parser - extracts image from cdata description +export async function getSomePicsPost(feedUrl) { + const res = await fetch(feedUrl) + const data = await res.text() + const dom = new JSDOM(data, { contentType: 'text/xml' }) + const item = dom.window.document.querySelector('item') + const title = item.querySelector('title').textContent + const link = item.querySelector('link').textContent.trim() + + // extract image from cdata description + const description = item.querySelector('description').textContent + const imgMatch = description.match(/]+src="([^"]+)"/) + const image = imgMatch ? imgMatch[1] : null + + return { text: title, url: link, image } +} + // ======================================================================== // music // ========================================================================