Skip to content

Commit

Permalink
Add Play All link when possible, parse more types
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkyProgrammer committed Nov 20, 2024
1 parent 4c2e832 commit 170e473
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/renderer/components/ChannelHome/ChannelHome.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,19 @@
border-color: var(--primary-color);
}

.playAllSpan {
font-size: large;
margin-inline-start: 10px;
}

.playAllLink {
font-style: italic;
padding-block: 5px;
padding-inline: 7px;
border-radius: 10px;
text-decoration: none;
}

.playAllLink:hover {
background-color: var(--bg-color);
}
18 changes: 18 additions & 0 deletions src/renderer/components/ChannelHome/ChannelHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@
class="shelfTitle"
>
{{ shelf.title }}
<span
v-if="shelf.playlistId"
class="playAllSpan"
>
<router-link
class="playAllLink"
:to="{
path: `/playlist/${shelf.playlistId}`,
query: searchSettings
}"
>
<FontAwesomeIcon
class="thumbnail"
:icon="['fas', 'play']"
/>
{{ $t('Channel.Home.Play all') }}
</router-link>
</span>
<hr class="shelfUnderline">
</summary>
<FtElementList
Expand Down
41 changes: 39 additions & 2 deletions src/renderer/helpers/api/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,8 @@ export function parseChannelHomeTab(homeTab) {
const shelf = itemSection.contents.at(0)
shelves.push({
title: shelf.title.text,
content: shelf.content.items.map(parseListItem).filter(_ => _)
content: shelf.content.items.map(parseListItem).filter(_ => _),
playlistId: shelf.play_all_button?.endpoint.payload.playlistId
})
} else if (itemSection.contents.at(0).type === 'ReelShelf') {
/** @type {import('youtubei.js').YTNodes.ReelShelf} */
Expand All @@ -893,6 +894,13 @@ export function parseChannelHomeTab(homeTab) {
title: shelf.title.text,
content: shelf.items.map(parseListItem).filter(_ => _)
})
} else if (itemSection.contents.at(0).type === 'HorizontalCardList') {
/** @type {import('youtubei.js').YTNodes.HorizontalCardList} */
const shelf = itemSection.contents.at(0)
shelves.push({
title: shelf.header.title.text,
content: shelf.cards.map(parseListItem).filter(_ => _)
})
}
} else if (section.type === 'RichSection') {
/** @type {import('youtubei.js').YTNodes.RichShelf} */
Expand Down Expand Up @@ -1053,13 +1061,28 @@ export function parseLocalListVideo(item) {
} else if (item.type === 'GridVideo') {
/** @type {import('youtubei.js').YTNodes.GridVideo} */
const video = item

let publishedText

if (video.published != null && !video.published.isEmpty()) {
publishedText = video.published.text
}

const published = calculatePublishedDate(
publishedText,
video.is_live,
video.is_upcoming || video.is_premiere,
video.upcoming
)

return {
type: 'video',
videoId: video.id,
title: video.title.text,
author: video.author?.name,
authorId: video.author?.id,
viewCount: video.views.text == null ? null : extractNumberFromString(video.views.text),
published,
lengthSeconds: Number(timestampToDuration(video.duration.text)),
isUpcoming: video.is_upcoming,
premiereDate: video.upcoming
Expand Down Expand Up @@ -1101,7 +1124,7 @@ export function parseLocalListVideo(item) {
author: video.author.name,
authorId: video.author.id,
description: video.description,
viewCount: video.view_count == null ? null : extractNumberFromString(video.view_count.text),
viewCount: isNaN(video.view_count) ? (video.short_view_count.text == null ? null : parseLocalSubscriberCount(video.short_view_count.text)) : extractNumberFromString(video.view_count.text),
published,
lengthSeconds: isNaN(video.duration.seconds) ? '' : video.duration.seconds,
liveNow: video.is_live,
Expand Down Expand Up @@ -1162,7 +1185,21 @@ function parseListItem(item) {
case 'Video':
case 'GridVideo':
case 'GridMovie':
case 'VideoCard':
return parseLocalListVideo(item)
case 'GameCard': {
/** @type {import('youtubei.js').YTNodes.GameCard} */
const channel = item
/** @type {import('youtubei.js').YTNodes.GameDetails} */
const game = channel.game
return {
type: 'channel',
dataSource: 'local',
thumbnail: game.box_art.at(0).url,
name: game.title.text,
id: game.endpoint.payload.browseId
}
}
case 'GridChannel': {
/** @type {import('youtubei.js').YTNodes.GridChannel} */
const channel = item
Expand Down
1 change: 1 addition & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ Channel:
Oldest: Oldest
Home:
Home: Home
Play all: Play all
Podcasts:
Podcasts: Podcasts
This channel does not currently have any podcasts: This channel does not currently have any podcasts
Expand Down

0 comments on commit 170e473

Please sign in to comment.