Skip to content

Commit

Permalink
fix(route): update mixcloud (#15236)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misaka13514 authored Apr 15, 2024
1 parent 1c45218 commit dc093eb
Show file tree
Hide file tree
Showing 2 changed files with 960 additions and 192 deletions.
32 changes: 26 additions & 6 deletions lib/routes/mixcloud/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ export const route: Route = {
supportPodcast: true,
supportScihub: false,
},
radar: [
{
source: ['mixcloud.com/:username/:type?'],
},
{
source: ['www.mixcloud.com/:username/:type?'],
},
],
name: 'User',
maintainers: ['Misaka13514'],
handler,
description: `| Shows | Favorites | History | Stream |
| ------- | --------- | ------- | ------ |
| uploads | favorites | listens | stream |`,
description: `| Shows | Reposts | Favorites | History | Stream |
| ------- | ------- | --------- | ------- | ------ |
| uploads | reposts | favorites | listens | stream |`,
};

async function handler(ctx) {
Expand All @@ -37,17 +45,19 @@ async function handler(ctx) {
};

const type = ctx.req.param('type') ?? 'uploads';
if (!['stream', 'uploads', 'favorites', 'listens'].includes(type)) {
throw new InvalidParameterError(`Invalid type: ${type}`);
}
const username = ctx.req.param('username');

const config = {
stream: { name: 'Stream', node: 'stream' },
uploads: { name: 'Shows', node: 'uploads' },
reposts: { name: 'Reposts', node: 'reposted' },
favorites: { name: 'Favorites', node: 'favorites' },
listens: { name: 'History', node: 'listeningHistory' },
};
if (!config[type]) {
throw new InvalidParameterError(`Invalid type: ${type}`);
}

const payloads = {
stream: {
query: queries.stream.query,
Expand All @@ -64,6 +74,16 @@ async function handler(ctx) {
username: ctx.req.param('username'),
},
orderBy: 'LATEST',
onlyAttributedTo: '',
hasAttributedTo: false,
},
},
reposts: {
query: queries.reposts.query,
variables: {
lookup: {
username: ctx.req.param('username'),
},
},
},
favorites: {
Expand Down
Loading

0 comments on commit dc093eb

Please sign in to comment.