Skip to content

Commit 79ccc08

Browse files
committed
fix issues with latest version of invidious
1 parent 91f6b1e commit 79ccc08

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

lib/videos/models/video.dart

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,38 @@ import 'package:clipious/settings/models/db/video_filter.dart';
33
import 'package:clipious/utils/models/sharelink.dart';
44
import 'package:clipious/videos/models/ided_video.dart';
55
import 'package:freezed_annotation/freezed_annotation.dart';
6-
import 'package:json_annotation/json_annotation.dart';
76

87
import '../../utils/models/image_object.dart';
98
import 'adaptive_format.dart';
109
import 'caption.dart';
1110
import 'format_stream.dart';
1211

12+
part 'video.freezed.dart';
1313
part 'video.g.dart';
1414

15-
part 'video.freezed.dart';
15+
/// Depending on versions, the published field can be a full formatted date or a timestamp
16+
/// sometimes the published field is like this
17+
///
18+
/// "published": 1738022400,
19+
///
20+
/// sometimes it is:
21+
///
22+
/// "published": "2025-01-28T19:00:26Z",
23+
int? _parsePublished(dynamic published) {
24+
if (published == null) return null;
25+
26+
if (published is int) {
27+
return published;
28+
} else if (published is String) {
29+
try {
30+
return DateTime.parse(published).millisecondsSinceEpoch ~/ 1000;
31+
} catch (e) {
32+
return null;
33+
}
34+
}
35+
36+
return null;
37+
}
1638

1739
@freezed
1840
class Video with _$Video implements ShareLinks, IdedVideo {
@@ -21,7 +43,7 @@ class Video with _$Video implements ShareLinks, IdedVideo {
2143
const factory Video(
2244
{required String videoId,
2345
int? viewCount,
24-
int? published,
46+
@JsonKey(fromJson: _parsePublished) int? published,
2547
int? index,
2648
String? indexId,
2749
String? publishedText,

lib/videos/models/video.freezed.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Video _$VideoFromJson(Map<String, dynamic> json) {
2222
mixin _$Video {
2323
String get videoId => throw _privateConstructorUsedError;
2424
int? get viewCount => throw _privateConstructorUsedError;
25+
@JsonKey(fromJson: _parsePublished)
2526
int? get published => throw _privateConstructorUsedError;
2627
int? get index => throw _privateConstructorUsedError;
2728
String? get indexId => throw _privateConstructorUsedError;
@@ -87,7 +88,7 @@ abstract class $VideoCopyWith<$Res> {
8788
$Res call(
8889
{String videoId,
8990
int? viewCount,
90-
int? published,
91+
@JsonKey(fromJson: _parsePublished) int? published,
9192
int? index,
9293
String? indexId,
9394
String? publishedText,
@@ -378,7 +379,7 @@ abstract class _$$VideoImplCopyWith<$Res> implements $VideoCopyWith<$Res> {
378379
$Res call(
379380
{String videoId,
380381
int? viewCount,
381-
int? published,
382+
@JsonKey(fromJson: _parsePublished) int? published,
382383
int? index,
383384
String? indexId,
384385
String? publishedText,
@@ -663,7 +664,7 @@ class _$VideoImpl extends _Video {
663664
const _$VideoImpl(
664665
{required this.videoId,
665666
this.viewCount,
666-
this.published,
667+
@JsonKey(fromJson: _parsePublished) this.published,
667668
this.index,
668669
this.indexId,
669670
this.publishedText,
@@ -728,6 +729,7 @@ class _$VideoImpl extends _Video {
728729
@override
729730
final int? viewCount;
730731
@override
732+
@JsonKey(fromJson: _parsePublished)
731733
final int? published;
732734
@override
733735
final int? index;
@@ -1035,7 +1037,7 @@ abstract class _Video extends Video implements ShareLinks, IdedVideo {
10351037
const factory _Video(
10361038
{required final String videoId,
10371039
final int? viewCount,
1038-
final int? published,
1040+
@JsonKey(fromJson: _parsePublished) final int? published,
10391041
final int? index,
10401042
final String? indexId,
10411043
final String? publishedText,
@@ -1090,6 +1092,7 @@ abstract class _Video extends Video implements ShareLinks, IdedVideo {
10901092
@override
10911093
int? get viewCount;
10921094
@override
1095+
@JsonKey(fromJson: _parsePublished)
10931096
int? get published;
10941097
@override
10951098
int? get index;

lib/videos/models/video.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shell.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ pkgs.mkShell {
4848
4949
echo "creating useful aliases..."
5050
51+
flutter config --jdk-dir ${pkgs.corretto17}/lib/corretto
52+
5153
''+
5254
pkgs.lib.concatStrings (map (x: ''alias ${x.name}="${x.command}";'') aliases)
5355
+''

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy