@@ -36,6 +36,26 @@ fun VideoStream.toPipedStream(): PipedStream = PipedStream(
36
36
contentLength = itagItem?.contentLength ? : 0L
37
37
)
38
38
39
+ fun StreamInfoItem.toStreamItem (
40
+ uploaderAvatarUrl : String? = null
41
+ ): StreamItem = StreamItem (
42
+ type = StreamItem .TYPE_STREAM ,
43
+ url = url.replace(YOUTUBE_FRONTEND_URL , " " ),
44
+ title = name,
45
+ uploaded = uploadDate?.offsetDateTime()?.toEpochSecond()?.times(1000 ) ? : 0 ,
46
+ uploadedDate = textualUploadDate ? : uploadDate?.offsetDateTime()?.toLocalDateTime()?.toLocalDate()
47
+ ?.toString(),
48
+ uploaderName = uploaderName,
49
+ uploaderUrl = uploaderUrl.replace(YOUTUBE_FRONTEND_URL , " " ),
50
+ uploaderAvatar = uploaderAvatarUrl ? : uploaderAvatars.maxByOrNull { it.height }?.url,
51
+ thumbnail = thumbnails.maxByOrNull { it.height }?.url,
52
+ duration = duration,
53
+ views = viewCount,
54
+ uploaderVerified = isUploaderVerified,
55
+ shortDescription = shortDescription,
56
+ isShort = isShortFormContent
57
+ )
58
+
39
59
object StreamsExtractor {
40
60
suspend fun extractStreams (videoId : String ): Streams {
41
61
if (! PlayerHelper .disablePipedProxy || ! PlayerHelper .localStreamExtraction) {
@@ -74,24 +94,7 @@ object StreamsExtractor {
74
94
uploadTimestamp = resp.uploadDate.offsetDateTime().toInstant().toKotlinInstant(),
75
95
uploaded = resp.uploadDate.offsetDateTime().toEpochSecond() * 1000 ,
76
96
thumbnailUrl = resp.thumbnails.maxBy { it.height }.url,
77
- relatedStreams = resp.relatedItems.filterIsInstance<StreamInfoItem >().map {
78
- StreamItem (
79
- it.url.replace(YOUTUBE_FRONTEND_URL , " " ),
80
- StreamItem .TYPE_STREAM ,
81
- it.name,
82
- it.thumbnails.maxBy { image -> image.height }.url,
83
- it.uploaderName,
84
- it.uploaderUrl.replace(YOUTUBE_FRONTEND_URL , " " ),
85
- it.uploaderAvatars.maxBy { image -> image.height }.url,
86
- it.textualUploadDate,
87
- it.duration,
88
- it.viewCount,
89
- it.isUploaderVerified,
90
- it.uploadDate?.offsetDateTime()?.toEpochSecond()?.times(1000 ) ? : 0L ,
91
- it.shortDescription,
92
- it.isShortFormContent,
93
- )
94
- },
97
+ relatedStreams = resp.relatedItems.filterIsInstance<StreamInfoItem >().map(StreamInfoItem ::toStreamItem),
95
98
chapters = resp.streamSegments.map {
96
99
ChapterSegment (
97
100
title = it.title,
0 commit comments