add artist images back
This commit is contained in:
parent
76f640a088
commit
a2f82d65d7
4 changed files with 51 additions and 10 deletions
|
@ -3911,6 +3911,21 @@ const app = new Vue({
|
||||||
checkForUpdate() {
|
checkForUpdate() {
|
||||||
ipcRenderer.send('check-for-update')
|
ipcRenderer.send('check-for-update')
|
||||||
},
|
},
|
||||||
|
async loadArtistImage(id){
|
||||||
|
try {
|
||||||
|
let u = await fetch(`https://music.apple.com/${app.mk.storefrontId}/artist/${id}`);
|
||||||
|
let html = await u.text();
|
||||||
|
function getStringBetween(str, start, end) {
|
||||||
|
const result = str.match(new RegExp(start + "(.*)" + end));
|
||||||
|
|
||||||
|
return result[1];
|
||||||
|
}
|
||||||
|
let string = getStringBetween(html, '<meta property="og:image:secure_url" content="', "cw.png").replace(`1200x630`, `300x300.png`);
|
||||||
|
return await string;
|
||||||
|
} catch (err) {
|
||||||
|
return await ''
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script type="text/x-template" id="artist-chip">
|
<script type="text/x-template" id="artist-chip">
|
||||||
<div class="artist-chip" @click.self="route">
|
<div class="artist-chip" @click.self="route">
|
||||||
<div class="artist-chip__image">
|
<div class="artist-chip__image">
|
||||||
<mediaitem-artwork v-if="artist.id != null" :url="artist.attributes.artwork.url" :size="32"></mediaitem-artwork>
|
<mediaitem-artwork v-if="artist.id != null" :url="artistimage" :size="32"></mediaitem-artwork>
|
||||||
</div>
|
</div>
|
||||||
<div class="artist-chip__name">
|
<div class="artist-chip__name">
|
||||||
<span>{{ item.attributes.name }}</span>
|
<span>{{ item.attributes.name }}</span>
|
||||||
|
@ -16,24 +16,30 @@
|
||||||
props: {
|
props: {
|
||||||
item: {
|
item: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
artist: {
|
artist: {
|
||||||
id: null
|
id: null
|
||||||
}
|
},
|
||||||
|
artistimage : ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: '#artist-chip',
|
template: '#artist-chip',
|
||||||
async mounted() {
|
async mounted() {
|
||||||
let artistId = this.item.id
|
let artistId = this.item.id
|
||||||
|
|
||||||
if(typeof this.item.relationships.catalog == "object") {
|
if(typeof this.item.relationships.catalog == "object") {
|
||||||
artistId = this.item.relationships.catalog.data[0].id
|
artistId = this.item.relationships.catalog.data[0].id
|
||||||
}
|
}
|
||||||
app.mk.api.music(`/v1/catalog/${app.mk.storefrontId}/artists/${artistId}`).then(response => {
|
app.mk.api.music(`/v1/catalog/${app.mk.storefrontId}/artists/${artistId}`).then(async (response) => {
|
||||||
this.artist = response.data.data[0];
|
this.artist = response.data.data[0];
|
||||||
|
if (this.artistimage == '' && artistId != null){
|
||||||
|
this.artistimage = (await this.$root.loadArtistImage(artistId) ?? '').replace('300x300','50x50')
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="artwork" @click='app.routeView(item)'>
|
<div class="artwork" @click='app.routeView(item)'>
|
||||||
<mediaitem-artwork
|
<mediaitem-artwork
|
||||||
:url="getArtworkUrl()"
|
:url="mainimageurl"
|
||||||
:video="(item.attributes != null && item.attributes.editorialVideo != null) ? (item.attributes.editorialVideo.motionDetailSquare ? item.attributes.editorialVideo.motionDetailSquare.video : (item.attributes.editorialVideo.motionSquareVideo1x1 ? item.attributes.editorialVideo.motionSquareVideo1x1.video : '')) : '' "
|
:video="(item.attributes != null && item.attributes.editorialVideo != null) ? (item.attributes.editorialVideo.motionDetailSquare ? item.attributes.editorialVideo.motionDetailSquare.video : (item.attributes.editorialVideo.motionSquareVideo1x1 ? item.attributes.editorialVideo.motionSquareVideo1x1.video : '')) : '' "
|
||||||
:size="size"
|
:size="size"
|
||||||
shadow="subtle"
|
shadow="subtle"
|
||||||
|
@ -77,7 +77,8 @@
|
||||||
app: this.$root,
|
app: this.$root,
|
||||||
badges: this.$root.socialBadges.badgeMap,
|
badges: this.$root.socialBadges.badgeMap,
|
||||||
itemBadges: [],
|
itemBadges: [],
|
||||||
unavailable: false
|
unavailable: false,
|
||||||
|
mainimageurl: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
|
@ -91,6 +92,7 @@
|
||||||
this.unavailable = true
|
this.unavailable = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.getMainImage()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getBgColor() {
|
getBgColor() {
|
||||||
|
@ -205,7 +207,10 @@
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
getArtworkUrl(size = -1, includeUrl = false) {
|
getArtworkUrl(size = -1, includeUrl = false) {
|
||||||
let artwork = this.item.attributes.artwork ? this.item.attributes.artwork.url : ''
|
let artwork = this.item.attributes?.artwork ? this.item.attributes.artwork?.url : ''
|
||||||
|
// if (artwork == '' && this.item.type == "artists" && this.item.id != null) {
|
||||||
|
// artwork = (await app.loadArtistImage(this.item.id)).toString();
|
||||||
|
// }
|
||||||
if(size != -1) {
|
if(size != -1) {
|
||||||
artwork = artwork.replace('{w}', size).replace('{h}', size).replace('{f}', "webp").replace('{c}', ((size === 900) ? "sr" : "cc"))
|
artwork = artwork.replace('{w}', size).replace('{h}', size).replace('{f}', "webp").replace('{c}', ((size === 900) ? "sr" : "cc"))
|
||||||
}
|
}
|
||||||
|
@ -220,6 +225,12 @@
|
||||||
return `url("${artwork}")`
|
return `url("${artwork}")`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async getMainImage(){
|
||||||
|
this.mainimageurl = this.getArtworkUrl()
|
||||||
|
if (this.mainimageurl == '' && this.item.id != null && this.item.type == "artists") {
|
||||||
|
this.mainimageurl = await this.app.loadArtistImage(this.item.id)
|
||||||
|
}
|
||||||
|
},
|
||||||
getClasses() {
|
getClasses() {
|
||||||
let type = this.item.type
|
let type = this.item.type
|
||||||
if (this.kind != "") {
|
if (this.kind != "") {
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<div class="artist-image" v-if="!(data.attributes.editorialVideo && (data.attributes.editorialVideo.motionArtistWide16x9 || data.attributes.editorialVideo.motionArtistFullscreen16x9))">
|
<div class="artist-image" v-if="!(data.attributes.editorialVideo && (data.attributes.editorialVideo.motionArtistWide16x9 || data.attributes.editorialVideo.motionArtistFullscreen16x9))">
|
||||||
<mediaitem-artwork
|
<mediaitem-artwork
|
||||||
shadow="large"
|
shadow="large"
|
||||||
:url="data.attributes?.artwork ? data.attributes.artwork?.url : ''"
|
:url="artistimage"
|
||||||
size="190" type="artists"></mediaitem-artwork>
|
size="190" type="artists"></mediaitem-artwork>
|
||||||
<button class="overlay-play" @click="app.mk.setStationQueue({artist:'a-'+data.id}).then(()=>{
|
<button class="overlay-play" @click="app.mk.setStationQueue({artist:'a-'+data.id}).then(()=>{
|
||||||
app.mk.play()
|
app.mk.play()
|
||||||
|
@ -143,9 +143,18 @@
|
||||||
return {
|
return {
|
||||||
topSongsExpanded: false,
|
topSongsExpanded: false,
|
||||||
app: this.$root,
|
app: this.$root,
|
||||||
headerVisible: true
|
headerVisible: true,
|
||||||
|
artistimage : ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted: async function () {
|
||||||
|
this.artistimage = this.data.attributes?.artwork ? this.data.attributes.artwork?.url : ''
|
||||||
|
|
||||||
|
if (this.artistimage == '' && this.data.id != null){
|
||||||
|
this.artistimage = await this.app.loadArtistImage(this.data.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
isHeaderVisible(visible) {
|
isHeaderVisible(visible) {
|
||||||
this.headerVisible = visible
|
this.headerVisible = visible
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue