feat(route): add MyMusicSheet User Sheets (#13444)
* feat: add mymusicsheet route * Update mymusicsheet route * fix: missing iso after the price * docs: add wikipedia page for ISO 4217 * docs: add empty line after MyMusicSheet * fix: wrong route data in maintainer.js * Update lib/v2/mymusicsheet/templates/description.art * Update lib/v2/mymusicsheet/templates/description.art ---------
This commit is contained in:
parent
744ae49151
commit
0192d810e8
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/user/sheets/:username/:iso?': ['Freddd13'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'mymusicsheet.com': {
|
||||
_name: 'MyMusicSheet',
|
||||
'.': [
|
||||
{
|
||||
title: 'User Sheets',
|
||||
docs: 'https://docs.rsshub.app/routes/shopping#mymusicsheet-user-sheets',
|
||||
source: [':username/*', '/:username'],
|
||||
target: '/mymusicsheet/user/sheets/:username',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/user/sheets/:username/:iso?', require('./usersheets'));
|
||||
};
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<div class="item-description">
|
||||
{{if youtubeId}}
|
||||
<iframe
|
||||
src="https://www.youtube-nocookie.com/embed/{{youtubeId}}?autoplay=0"
|
||||
style="width:100%; height:100%;"
|
||||
frameborder="0"
|
||||
allow="autoplay; encrypted-media; picture-in-picture"
|
||||
allowfullscreen>
|
||||
</iframe>
|
||||
{{/if}}
|
||||
|
||||
{{if content.musicName}}
|
||||
<p>Music Name: {{content.musicName}}</p>
|
||||
{{/if}}
|
||||
|
||||
{{if content.musicMemo}}
|
||||
<p>Music Memo: {{content.musicMemo}}</p>
|
||||
{{/if}}
|
||||
|
||||
{{if content.musicianName}}
|
||||
<p>Musician Name: {{content.musicianName}}</p>
|
||||
{{/if}}
|
||||
|
||||
{{if content.author}}
|
||||
<p>Author: {{content.author}}</p>
|
||||
{{/if}}
|
||||
|
||||
{{if content.instruments && content.instruments.length}}
|
||||
<p>Instruments:
|
||||
{{each content.instruments}}{{$value}} {{/each}}
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
{{if content.status}}
|
||||
<p>Status: {{content.status}}</p>
|
||||
{{/if}}
|
||||
|
||||
{{if content.price}}
|
||||
<p>Price: {{content.price}}</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://www.mymusicsheet.com';
|
||||
const graphqlUrl = 'https://mms.pd.mapia.io/mms/graphql';
|
||||
const exchangeRateUrl = 'https://payport.pd.mapia.io/v2/currency';
|
||||
const { username, iso = 'CNY' } = ctx.params;
|
||||
|
||||
const exchangeRateResponse = await got(exchangeRateUrl, {
|
||||
searchParams: {
|
||||
serviceProvider: 'mms',
|
||||
'ngsw-bypass': true,
|
||||
'no-cache': Date.now(),
|
||||
skipHeaders: true,
|
||||
},
|
||||
responseType: 'json',
|
||||
});
|
||||
const rates = exchangeRateResponse.data;
|
||||
|
||||
const response = await got.post(graphqlUrl, {
|
||||
json: {
|
||||
operationName: 'loadArtistSheets',
|
||||
query: `
|
||||
query loadArtistSheets($data: SheetSearchInput!) {
|
||||
sheetSearch(data: $data) {
|
||||
list {
|
||||
productId
|
||||
productType
|
||||
metaSong
|
||||
metaMaker
|
||||
metaMusician
|
||||
metaMemo
|
||||
instruments
|
||||
level
|
||||
price
|
||||
sheetId
|
||||
status
|
||||
author {
|
||||
name
|
||||
artistUrl
|
||||
profileUrl
|
||||
}
|
||||
youtubeId
|
||||
title
|
||||
supportCountry
|
||||
excludeCountries
|
||||
__typename
|
||||
}
|
||||
total
|
||||
current
|
||||
listNum
|
||||
}
|
||||
}`,
|
||||
variables: {
|
||||
data: {
|
||||
listNum: 10,
|
||||
paginate: 'page',
|
||||
includeChord: null,
|
||||
includeLyrics: null,
|
||||
page: 1,
|
||||
level: null,
|
||||
instruments: [],
|
||||
orderBy: {
|
||||
createdAt: 'DESC',
|
||||
},
|
||||
isFree: null,
|
||||
category: null,
|
||||
artistUrl: username,
|
||||
aggregationKeywords: ['PACKAGE_IDS', 'TAG_IDS', 'INSTRUMENTS', 'SHEET_TYPE', 'INCLUDE_CHORD', 'INCLUDE_LYRICS', 'INSTRUMENTATION', 'LEVEL', 'CATEGORY'],
|
||||
aggregationKeySize: 20,
|
||||
},
|
||||
},
|
||||
},
|
||||
responseType: 'json',
|
||||
});
|
||||
|
||||
const sheetSearch = response.data.data.sheetSearch.list;
|
||||
const items = sheetSearch.map((item) => {
|
||||
let finalPrice = 'Unknown';
|
||||
const price = parseFloat(item.price);
|
||||
|
||||
if (item.price === 0) {
|
||||
finalPrice = 'Free';
|
||||
} else if (!isNaN(price) && isFinite(price)) {
|
||||
const rate = rates[iso];
|
||||
if (rate) {
|
||||
finalPrice = `${(price * rate).toFixed(2)} ${iso}`;
|
||||
}
|
||||
}
|
||||
|
||||
const youtubeId = item.youtubeId;
|
||||
const content = {
|
||||
musicName: item.metaSong,
|
||||
musicMemo: item.metaMemo,
|
||||
musicianName: item.metaMusician,
|
||||
author: item.author.name,
|
||||
instruments: item.instruments,
|
||||
status: item.status,
|
||||
price: finalPrice,
|
||||
};
|
||||
|
||||
return {
|
||||
title: `${item.author.name} | ${item.title} | ${finalPrice}`,
|
||||
link: `${baseUrl}/${username}/${item.sheetId}`,
|
||||
itunes_item_image: item.author.profileUrl,
|
||||
description: art(path.join(__dirname, 'templates/description.art'), {
|
||||
youtubeId,
|
||||
content,
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${username}'s sheets`,
|
||||
link: `https://www.mymusicsheet.com/${username}?viewType=sheet&orderBy=createdAt`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -268,6 +268,14 @@ Language
|
|||
|
||||
</Route>
|
||||
|
||||
## MyMusicSheet {#mymusicsheet}
|
||||
|
||||
### User Sheets {#mymusicsheet-user-sheets}
|
||||
|
||||
<Route author="Freddd13" example="/mymusicsheet/HalcyonMusic" path="/mymusicsheet/user/sheets/:username/:iso?" paramsDesc={['用户名,可在URL中找到', '用于显示价格的ISO 4217货币代码, 支持常见代码, 默认为人民币, 即`CNY`']} radar="1" rssbud="1"/>
|
||||
|
||||
关于ISO 4217,请参考[维基百科](https://zh.wikipedia.org/zh-cn/ISO_4217#%E7%8E%B0%E8%A1%8C%E4%BB%A3%E7%A0%81)
|
||||
|
||||
## Patagonia {#patagonia}
|
||||
|
||||
### New Arrivals {#patagonia-new-arrivals}
|
||||
|
|
|
|||
Loading…
Reference in New Issue