Skip to content

Commit

Permalink
Merge pull request #598 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Nov 26, 2022
2 parents 1a7b934 + 7a9762b commit 649641f
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 5 deletions.
6 changes: 6 additions & 0 deletions docs/en/social-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ pageClass: routes

<RouteEn author="lucasew" path="/curiouscat/user/:name" example="/curiouscat/user/kretyn" :paramsDesc="['name, username that is in the URL']" />

## Curius

### User

<RouteEn author="Ovler-Young" example="/curius/links/yuu-yuu" path="/curius/links/:name" :paramsDesc="['Username, can be found in URL']"/>

## Dev.to

### Top Posts
Expand Down
6 changes: 6 additions & 0 deletions docs/social-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性

</Route>

## Curius

### 用户

<Route author="Ovler-Young" example="/curius/links/yuu-yuu" path="/curius/links/:name" :paramsDesc="['用户名称,可在url中找到']"/>

## Dev.to

### 最高职位
Expand Down
43 changes: 43 additions & 0 deletions lib/v2/curius/links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');

module.exports = async (ctx) => {
const username = ctx.params.name;

const name_response = await got(`https://curius.app/api/users/${username}`, {
headers: {
Referer: `https://curius.app/${username}`,
},
});

const data = name_response.data;

const uid = data.user.id;
const name = `${data.user.firstName} ${data.user.lastName}`;

const response = await got(`https://curius.app/api/users/${uid}/links?page=0`, {
headers: {
Referer: `https://curius.app/${username}`,
},
});

const items = response.data.userSaved.map((item) => ({
title: item.title,
description: art(path.join(__dirname, 'templates/description.art'), {
item,
}),
link: item.link,
pubDate: parseDate(item.createdDate),
guid: `curius:${username}:${item.id}`,
}));

ctx.state.data = {
title: `${name} - Curius`,
link: `https://curius.app/${username}`,
description: `${name} - Curius`,
allowEmpty: true,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/curius/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/links/:name': ['Ovler-Young'],
};
13 changes: 13 additions & 0 deletions lib/v2/curius/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'curius.app': {
_name: 'Curius',
'.': [
{
title: '用户',
docs: 'https://docs.rsshub.app/social-media.html#curius',
source: '/:name',
target: '/curius/links/:name',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/curius/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/links/:name', require('./links'));
};
16 changes: 16 additions & 0 deletions lib/v2/curius/templates/description.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{ if item.metadata.full_text }}
原文:{{@ item.metadata.full_text.replace(/\n/gm, '<br>') }}<br><br>
{{ /if }}
{{ if item.comments.length }}
评论:{{ item.comments[0].text.substring(0, 100) }}<br><br>
{{ /if }}
{{ if item.highlights.length }}
评论:
{{ each item.highlights highlight }}
{{ if highlight.comment }}
{{ highlight.highlight }}<br>评论:{{ highlight.comment.text }}<br>
{{ else }}
<br>标注:{{ highlight.highlight }}<br>
{{ /if }}
{{ /each }}
{{ /if }}
16 changes: 11 additions & 5 deletions lib/v2/telegram/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const STICKER = 'STICKER';
const ANIMATED_STICKER = 'ANIMATED_STICKER';
// const VIDEO_STICKER = 'VIDEO_STICKER'; // not supported yet by t.me
const UNSUPPORTED = 'UNSUPPORTED';
const PARTIALLY_UNSUPPORTED = 'PARTIALLY_UNSUPPORTED';

/* message media tag dict */
const mediaTagDict = {
Expand All @@ -45,6 +46,7 @@ const mediaTagDict = {
ANIMATED_STICKER: ['[Animated Sticker]', '[Animated Sticker]'],
// VIDEO_STICKER: ['[Video Sticker]', '[Video Sticker]'], // not supported yet by t.me
UNSUPPORTED: ['[Unsupported]', '🚫'],
PARTIALLY_UNSUPPORTED: ['', ''],
};

module.exports = async (ctx) => {
Expand Down Expand Up @@ -157,10 +159,14 @@ module.exports = async (ctx) => {
if (item.find('.tgme_widget_message_tgsticker').length) {
msgTypes.push(ANIMATED_STICKER);
}
if (msgTypes.length === 0 && item.find('.message_media_not_supported').length) {
msgTypes.unshift(UNSUPPORTED);
if (!includeUnsupportedMsg) {
return null; // drop unsupported message
if (item.find('.message_media_not_supported').length) {
if (item.find('.media_supported_cont').length) {
msgTypes.unshift(PARTIALLY_UNSUPPORTED);
} else {
if (msgTypes.length === 0 && !includeUnsupportedMsg) {
return null; // drop unsupported message
}
msgTypes.unshift(UNSUPPORTED);
}
}
// all other types above cannot be mixed
Expand Down Expand Up @@ -496,7 +502,7 @@ module.exports = async (ctx) => {
const pubDate = parseDate(item.find('.tgme_widget_message_date time').attr('datetime'));

/* message text & title */
const messageTextObj = item.find('.tgme_widget_message_bubble > .tgme_widget_message_text');
const messageTextObj = item.find(`.${msgTypes.includes(PARTIALLY_UNSUPPORTED) ? 'media_supported_cont' : 'tgme_widget_message_bubble'} > .tgme_widget_message_text`);
let messageHtml = '',
messageTitle = '';

Expand Down

1 comment on commit 649641f

@vercel
Copy link

@vercel vercel bot commented on 649641f Nov 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.