fix: Support itunes_category and itunes_explicit (#4610)

This commit is contained in:
Zhi Yang 2020-05-11 18:28:49 +08:00 committed by GitHub
parent 9fdfb87e18
commit 64496ca55d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -2,6 +2,16 @@ const got = require('@/utils/got');
const baseUrl = 'http://www.ximalaya.com';
const got_ins = got.extend({});
// Find category from: https://help.apple.com/itc/podcasts_connect/?lang=en#/itc9267a2f12
const categoryDict = {
人文: 'Society & Culture',
历史: 'History',
头条: 'News',
娱乐: 'Leisure',
音乐: 'Music',
IT科技: 'Technology',
};
module.exports = async (ctx) => {
const id = ctx.params.id; // 专辑id
const isAll = ctx.params.all ? true : false;
@ -66,8 +76,6 @@ module.exports = async (ctx) => {
enclosure_url: enclosure_url,
enclosure_length: enclosure_length,
enclosure_type: 'audio/x-m4a',
itunes_category: album_category,
itunes_explicit: 'clean', // 内容是否为限制级
};
return Promise.resolve(resultItem);
})
@ -79,7 +87,7 @@ module.exports = async (ctx) => {
description: album_desc,
image: album_cover,
itunes_author: author,
itunes_category: album_category,
itunes_category: categoryDict[album_category] || album_category,
item: resultItems,
};
};

View File

@ -15,6 +15,7 @@
<webMaster>i@diygod.me (DIYgod)</webMaster>
{{ if itunes_author }}<itunes:author>{{ itunes_author}}</itunes:author>{{ /if }}
{{ if itunes_category }}<itunes:category text="{{ itunes_category }}"/>{{ /if }}
{{ if itunes_author }}<itunes:explicit>{{ itunes_explicit || 'clean' }}</itunes:explicit>{{ /if }}
<language>{{ language || 'zh-cn' }}</language>
{{ if image }}
<image>
@ -35,8 +36,6 @@
{{ if $value.itunes_item_image }}<itunes:image href="{{ $value.itunes_item_image }}"/>{{ /if }}
{{ if $value.enclosure_url }}<enclosure url="{{ $value.enclosure_url }}" {{ if $value.enclosure_length }}length="{{ $value.enclosure_length }}"{{ /if }} {{ if $value.enclosure_type }}type="{{ $value.enclosure_type }}"{{ /if }} />{{ /if }}
{{ if itunes_author && $value.itunes_duration }}<itunes:duration>{{ $value.itunes_duration }}</itunes:duration> {{ /if }}
{{ if itunes_author && $value.itunes_category }}<itunes:category>{{ $value.itunes_category }}</itunes:category> {{ /if }}
{{ if itunes_author && $value.itunes_explicit }}<itunes:explicit>{{ $value.itunes_explicit }}</itunes:explicit> {{ /if }}
{{ if $value.author }}<author><![CDATA[{{ $value.author }}]]></author>{{ /if }}
{{ if typeof $value.category === 'string' }}
<category>{{ $value.category }}</category>