Skip to content

Commit

Permalink
fix(route): update mixcloud queries (#13319)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misaka13514 authored Sep 16, 2023
1 parent 9f76883 commit 0d0f482
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 201 deletions.
27 changes: 5 additions & 22 deletions lib/v2/mixcloud/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { queries } = require('./queries');
module.exports = async (ctx) => {
const host = 'https://www.mixcloud.com';
const imageBaseURL = 'https://thumbnailer.mixcloud.com/unsafe/480x480/';
const graphqlURL = 'https://app.mixcloud.com/graphql';
const headers = {
Referer: host,
'Content-Type': 'application/json',
Expand Down Expand Up @@ -40,7 +41,6 @@ module.exports = async (ctx) => {
username: ctx.params.username,
},
orderBy: 'LATEST',
audioTypes: ['SHOW'],
},
},
favorites: {
Expand All @@ -59,37 +59,20 @@ module.exports = async (ctx) => {
},
},
},
profile: {
query: queries.profile.query,
variables: {
lookup: {
username: ctx.params.username,
},
},
},
};

const profile = (
await got({
method: 'post',
url: `${host}/graphql`,
json: payloads.profile,
headers,
})
).data.data;

const biog = profile.user.biog;
const image = `${imageBaseURL}${profile.user.picture.urlRoot}`;

const data = (
await got({
method: 'post',
url: `${host}/graphql`,
url: graphqlURL,
json: payloads[type],
headers,
})
).data.data;

const biog = data.user.biog;
const image = `${imageBaseURL}${data.user.picture.urlRoot}`;

// https://github.com/ytdl-org/youtube-dl/blob/f1487d4fca40fd37d735753e24a7bae53a1b1513/youtube_dl/extractor/mixcloud.py#L72-L79
const decryptionKey = 'IFYOUWANTTHEARTISTSTOGETPAIDDONOTDOWNLOADFROMMIXCLOUD';
const decryptXorCipher = (key, cipherText) => {
Expand Down
Loading

0 comments on commit 0d0f482

Please sign in to comment.