Skip to content

Commit

Permalink
chore: fallback for channel thumbnail in video cards
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Nov 20, 2024
1 parent c05a630 commit e898206
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/youtube/controller/info_controllers/yt_various_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class _YoutubeInfoUtils {
_getVideoPageResultSync(videoId)?.channelInfo?.id.nullifyEmpty();
}

List<YoutiPieThumbnail>? getVideoChannelThumbnails(String videoId, {bool checkFromStorage = true}) {
var thumbnails = tempVideoInfosFromStreams[videoId]?.channel.thumbnails;
if ((thumbnails != null && thumbnails.isNotEmpty) || checkFromStorage == false) return thumbnails;
return getStreamInfoSync(videoId)?.channel.thumbnails ?? _getVideoPageResultSync(videoId)?.channelInfo?.thumbnails;
}

DateTime? getVideoReleaseDate(String videoId) {
// -- we check for streams result first cuz others are approximation.
return _tempInfoVideoReleaseDate[videoId] ??= _getVideoStreamResultSync(videoId)?.info?.publishedAt.date ??
Expand Down
1 change: 1 addition & 0 deletions lib/youtube/controller/youtube_info_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:youtipie/class/result_wrapper/search_result.dart';
import 'package:youtipie/class/stream_info_item/stream_info_item.dart';
import 'package:youtipie/class/streams/video_stream_info.dart';
import 'package:youtipie/class/streams/video_streams_result.dart';
import 'package:youtipie/class/thumbnail.dart';
import 'package:youtipie/class/videos/video_result.dart';
import 'package:youtipie/core/enum.dart';
import 'package:youtipie/core/http.dart';
Expand Down
9 changes: 7 additions & 2 deletions lib/youtube/widgets/yt_video_card.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';

import 'package:jiffy/jiffy.dart';
import 'package:namida/youtube/controller/youtube_info_controller.dart';
import 'package:playlist_manager/module/playlist_id.dart';
import 'package:youtipie/class/result_wrapper/playlist_result.dart';
import 'package:youtipie/class/result_wrapper/playlist_result_base.dart';
Expand Down Expand Up @@ -98,9 +99,13 @@ class YoutubeVideoCard extends StatelessWidget {
if (uploadDateAgo != null) uploadDateAgo,
].join(' - '),
displaythirdLineText: showThirdLine,
thirdLineText: dateInsteadOfChannel ? video.badges?.join(' - ') ?? '' : video.channel.title,
thirdLineText: dateInsteadOfChannel
? video.badges?.join(' - ') ?? ''
: video.channel.title.isNotEmpty
? video.channel.title
: video.channelName ?? '',
displayChannelThumbnail: !dateInsteadOfChannel,
channelThumbnailUrl: video.channel.thumbnails.pick()?.url,
channelThumbnailUrl: video.channel.thumbnails.pick()?.url ?? YoutubeInfoController.utils.getVideoChannelThumbnails(videoId, checkFromStorage: false)?.pick()?.url,
onTap: onTap ??
() async {
_VideoCardUtils.onVideoTap(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 4.7.01-beta+241120010
version: 4.7.02-beta+241120011

environment:
sdk: ">=3.4.0 <4.0.0"
Expand Down

0 comments on commit e898206

Please sign in to comment.