chore: pre-commit ci hook, dart format

This commit is contained in:
edde746
2026-04-18 12:40:35 +02:00
parent 2bd9e6655f
commit 3da51f9d64
128 changed files with 2056 additions and 2048 deletions
+2 -10
View File
@@ -9,11 +9,7 @@ class CaptureBuffer {
final double seekStartSeconds;
final double seekEndSeconds;
const CaptureBuffer({
required this.startedAt,
required this.seekStartSeconds,
required this.seekEndSeconds,
});
const CaptureBuffer({required this.startedAt, required this.seekStartSeconds, required this.seekEndSeconds});
/// Absolute epoch second of the earliest seekable point.
int get seekableStartEpoch => (startedAt + seekStartSeconds).round();
@@ -31,11 +27,7 @@ class CaptureBuffer {
final minOffset = _parseDouble(session['minOffsetAvailable']);
final maxOffset = _parseDouble(session['maxOffsetAvailable']);
if (timeStamp == null || minOffset == null || maxOffset == null) return null;
return CaptureBuffer(
startedAt: timeStamp,
seekStartSeconds: minOffset,
seekEndSeconds: maxOffset,
);
return CaptureBuffer(startedAt: timeStamp, seekStartSeconds: minOffset, seekEndSeconds: maxOffset);
}
static double? _parseDouble(dynamic value) {
+13 -9
View File
@@ -36,13 +36,23 @@ class LiveTvChannel {
factory LiveTvChannel.fromJson(Map<String, dynamic> json) {
return LiveTvChannel(
key: json['key'] as String? ?? json['ratingKey'] as String? ?? json['identifier'] as String? ?? json['id'] as String? ?? json['channelIdentifier'] as String? ?? '',
key:
json['key'] as String? ??
json['ratingKey'] as String? ??
json['identifier'] as String? ??
json['id'] as String? ??
json['channelIdentifier'] as String? ??
'',
identifier: json['identifier'] as String? ?? json['id'] as String? ?? json['channelIdentifier'] as String?,
callSign: json['callSign'] as String?,
title: json['title'] as String? ?? json['callSign'] as String?,
thumb: json['thumb'] as String?,
art: json['art'] as String?,
number: json['number'] as String? ?? json['channelNumber'] as String? ?? json['channelVcn']?.toString() ?? json['vcn']?.toString(),
number:
json['number'] as String? ??
json['channelNumber'] as String? ??
json['channelVcn']?.toString() ??
json['vcn']?.toString(),
hd: flexibleBool(json['hd']),
lineup: json['lineup'] as String?,
slug: json['slug'] as String?,
@@ -81,13 +91,7 @@ class FavoriteChannel {
final String? thumb;
final String? vcn;
FavoriteChannel({
required this.source,
required this.id,
this.title,
this.thumb,
this.vcn,
});
FavoriteChannel({required this.source, required this.id, this.title, this.thumb, this.vcn});
factory FavoriteChannel.fromJson(Map<String, dynamic> json) {
return FavoriteChannel(
+1 -4
View File
@@ -44,10 +44,7 @@ class LiveTvProgram {
this.premiere,
});
factory LiveTvProgram.fromJson(
Map<String, dynamic> json, {
Map<String, dynamic>? mediaOverride,
}) {
factory LiveTvProgram.fromJson(Map<String, dynamic> json, {Map<String, dynamic>? mediaOverride}) {
// Grid endpoint nests timing/channel info inside Media[] and Channel[].
// When mediaOverride is supplied, the caller is pinning this parse to a
// specific airing (one Media entry); treat it as authoritative for
+1 -5
View File
@@ -14,9 +14,5 @@ class MpvPreset {
);
}
Map<String, dynamic> toJson() => {
'name': name,
'text': text,
'createdAt': createdAt.toIso8601String(),
};
Map<String, dynamic> toJson() => {'name': name, 'text': text, 'createdAt': createdAt.toIso8601String()};
}
+3 -1
View File
@@ -61,7 +61,9 @@ class PlexHub {
return PlexHub(
hubKey: json['key'] as String? ?? '',
title: kBlurArtwork ? obfuscateText(json['title'] as String? ?? 'Unknown') : json['title'] as String? ?? 'Unknown',
title: kBlurArtwork
? obfuscateText(json['title'] as String? ?? 'Unknown')
: json['title'] as String? ?? 'Unknown',
type: json['type'] as String? ?? 'hub',
hubIdentifier: json['hubIdentifier'] as String?,
size: (json['size'] as num?)?.toInt() ?? metadataList.length,
+35 -32
View File
@@ -37,30 +37,34 @@ class PlexMediaInfo {
try {
final streamType = s['streamType'] as int?;
if (streamType == 2) {
audioTracks.add(PlexAudioTrack(
id: s['id'] as int,
index: s['index'] as int?,
codec: s['codec'] as String?,
language: s['language'] as String?,
languageCode: s['languageCode'] as String?,
title: s['title'] as String?,
displayTitle: s['displayTitle'] as String?,
channels: s['channels'] as int?,
selected: flexibleBool(s['selected']),
));
audioTracks.add(
PlexAudioTrack(
id: s['id'] as int,
index: s['index'] as int?,
codec: s['codec'] as String?,
language: s['language'] as String?,
languageCode: s['languageCode'] as String?,
title: s['title'] as String?,
displayTitle: s['displayTitle'] as String?,
channels: s['channels'] as int?,
selected: flexibleBool(s['selected']),
),
);
} else if (streamType == 3) {
subtitleTracks.add(PlexSubtitleTrack(
id: s['id'] as int,
index: s['index'] as int?,
codec: s['codec'] as String?,
language: s['language'] as String?,
languageCode: s['languageCode'] as String?,
title: s['title'] as String?,
displayTitle: s['displayTitle'] as String?,
selected: flexibleBool(s['selected']),
forced: flexibleBool(s['forced']),
key: s['key'] as String?,
));
subtitleTracks.add(
PlexSubtitleTrack(
id: s['id'] as int,
index: s['index'] as int?,
codec: s['codec'] as String?,
language: s['language'] as String?,
languageCode: s['languageCode'] as String?,
title: s['title'] as String?,
displayTitle: s['displayTitle'] as String?,
selected: flexibleBool(s['selected']),
forced: flexibleBool(s['forced']),
key: s['key'] as String?,
),
);
}
} catch (e) {
appLogger.d('Skipping malformed stream in cached metadata', error: e);
@@ -68,12 +72,7 @@ class PlexMediaInfo {
}
}
return PlexMediaInfo(
videoUrl: '',
audioTracks: audioTracks,
subtitleTracks: subtitleTracks,
chapters: const [],
);
return PlexMediaInfo(videoUrl: '', audioTracks: audioTracks, subtitleTracks: subtitleTracks, chapters: const []);
}
}
@@ -259,7 +258,12 @@ class PlaybackExtras {
if (m.type == 'intro' || m.type == 'credits') return m;
final newType = _classifyChapterTitle(m.type, introPattern, creditsPattern);
if (newType != null) {
return PlexMarker(id: m.id, type: newType, startTimeOffset: m.startTimeOffset, endTimeOffset: m.endTimeOffset);
return PlexMarker(
id: m.id,
type: newType,
startTimeOffset: m.startTimeOffset,
endTimeOffset: m.endTimeOffset,
);
}
return m;
}).toList();
@@ -278,8 +282,7 @@ class PlaybackExtras {
final start = ch.startTimeOffset;
if (start == null) continue;
final end = ch.endTimeOffset ??
(i + 1 < chapters.length ? chapters[i + 1].startTimeOffset : null);
final end = ch.endTimeOffset ?? (i + 1 < chapters.length ? chapters[i + 1].startTimeOffset : null);
if (end == null) continue;
synthetic.add(PlexMarker(id: ch.id, type: type, startTimeOffset: start, endTimeOffset: end));
+10 -11
View File
@@ -11,11 +11,9 @@ import '../utils/json_utils.dart';
part 'plex_metadata.g.dart';
Object? _readRatingKey(Map json, String key) =>
json['ratingKey'] ?? json['key'] ?? '';
Object? _readRatingKey(Map json, String key) => json['ratingKey'] ?? json['key'] ?? '';
List<String>? _tagsFromJson(List? json) =>
json?.cast<Map<String, dynamic>>().map((e) => e['tag'] as String).toList();
List<String>? _tagsFromJson(List? json) => json?.cast<Map<String, dynamic>>().map((e) => e['tag'] as String).toList();
/// Media type enum for type-safe media type handling
enum PlexMediaType {
@@ -156,10 +154,7 @@ class PlexMetadata with MultiServerFields {
/// For an episode: [seasonRatingKey, showRatingKey]
/// For a season: [showRatingKey]
/// For a movie: []
List<String> get parentChain => [
?parentRatingKey,
?grandparentRatingKey,
];
List<String> get parentChain => [?parentRatingKey, ?grandparentRatingKey];
/// Whether this item represents a library section (shared whole-library, not a media item).
/// These have keys like `/library/sections/5/all` instead of `/library/metadata/12345`.
@@ -548,9 +543,13 @@ class PlexMetadata with MultiServerFields {
try {
return _$PlexMetadataFromJson(kBlurArtwork ? _obfuscateJson(json) : json);
} on TypeError catch (e, st) {
Sentry.captureException(e, stackTrace: st, withScope: (scope) {
scope.setContexts('json', json);
});
Sentry.captureException(
e,
stackTrace: st,
withScope: (scope) {
scope.setContexts('json', json);
},
);
rethrow;
}
}