@@ -526,77 +526,18 @@ export function parseLocalChannelVideos(videos, channelId, channelName) {
526
526
*/
527
527
export function parseLocalChannelShorts ( shorts , channelId , channelName ) {
528
528
return shorts . map ( short => {
529
- // unfortunately the only place with the duration is the accesibility string
530
- const duration = parseShortDuration ( short . accessibility_label , short . id )
531
-
532
529
return {
533
530
type : 'video' ,
534
531
videoId : short . id ,
535
532
title : short . title . text ,
536
533
author : channelName ,
537
534
authorId : channelId ,
538
535
viewCount : parseLocalSubscriberCount ( short . views . text ) ,
539
- lengthSeconds : isNaN ( duration ) ? '' : duration
536
+ lengthSeconds : ''
540
537
}
541
538
} )
542
539
}
543
540
544
- /**
545
- * Shorts can only be up to 60 seconds long, so we only need to handle seconds and minutes
546
- * Of course this is YouTube, so are edge cases that don't match the docs, like example 3 taken from LTT
547
- *
548
- * https://support.google.com/youtube/answer/10059070?hl=en
549
- *
550
- * Example input strings:
551
- * - These mice keep getting WEIRDER... - 59 seconds - play video
552
- * - How Low Can Our Resolution Go? - 1 minute - play video
553
- * - I just found out about Elon. #SHORTS - 1 minute, 1 second - play video
554
- * @param {string } accessibilityLabel
555
- * @param {string } videoId only used for error logging
556
- */
557
- function parseShortDuration ( accessibilityLabel , videoId ) {
558
- // we want to count from the end of the array,
559
- // as it's possible that the title could contain a `-` too
560
- const timeString = accessibilityLabel . split ( '-' ) . at ( - 2 )
561
-
562
- if ( typeof timeString === 'undefined' ) {
563
- console . error ( `Failed to parse local API short duration from accessibility label. video ID: ${ videoId } , text: "${ accessibilityLabel } "` )
564
- return NaN
565
- }
566
-
567
- let duration = 0
568
-
569
- const matches = timeString . matchAll ( / ( \d + ) ( s e c o n d | m i n u t e ) s ? / g)
570
-
571
- // matchAll returns an iterator, which doesn't have a length property
572
- // so we need to check if it's empty this way instead
573
- let validDuration = false
574
-
575
- for ( const match of matches ) {
576
- let number = parseInt ( match [ 1 ] )
577
-
578
- if ( isNaN ( number ) || match [ 2 ] . length === 0 ) {
579
- validDuration = false
580
- break
581
- }
582
-
583
- validDuration = true
584
-
585
- if ( match [ 2 ] === 'minute' ) {
586
- number *= 60
587
- }
588
-
589
- duration += number
590
- }
591
-
592
- if ( ! validDuration ) {
593
- console . error ( `Failed to parse local API short duration from accessibility label. video ID: ${ videoId } , text: "${ accessibilityLabel } "` )
594
- return NaN
595
- }
596
-
597
- return duration
598
- }
599
-
600
541
/**
601
542
* @typedef {import('youtubei.js').YTNodes.Playlist } Playlist
602
543
* @typedef {import('youtubei.js').YTNodes.GridPlaylist } GridPlaylist
@@ -678,15 +619,12 @@ export function parseLocalPlaylistVideo(video) {
678
619
/** @type {import('youtubei.js').YTNodes.ReelItem } */
679
620
const short = video
680
621
681
- // unfortunately the only place with the duration is the accesibility string
682
- const duration = parseShortDuration ( video . accessibility_label , short . id )
683
-
684
622
return {
685
623
type : 'video' ,
686
624
videoId : short . id ,
687
625
title : short . title . text ,
688
626
viewCount : parseLocalSubscriberCount ( short . views . text ) ,
689
- lengthSeconds : isNaN ( duration ) ? '' : duration
627
+ lengthSeconds : ''
690
628
}
691
629
} else {
692
630
/** @type {import('youtubei.js').YTNodes.PlaylistVideo } */
0 commit comments