diff --git a/lib/entities/cache_track.dart b/lib/entities/cache_track.dart deleted file mode 100644 index bd42b9cf1..000000000 --- a/lib/entities/cache_track.dart +++ /dev/null @@ -1,101 +0,0 @@ -import 'package:hive/hive.dart'; -import 'package:youtube_explode_dart/youtube_explode_dart.dart'; - -part 'cache_track.g.dart'; - -@HiveType(typeId: 2) -class CacheTrackEngagement { - @HiveField(0) - late int viewCount; - - @HiveField(1) - late int? likeCount; - - @HiveField(2) - late int? dislikeCount; - - CacheTrackEngagement(); - - CacheTrackEngagement.fromEngagement(Engagement engagement) - : viewCount = engagement.viewCount, - likeCount = engagement.likeCount, - dislikeCount = engagement.dislikeCount; -} - -@HiveType(typeId: 3) -class CacheTrackSkipSegment { - @HiveField(0) - late int start; - @HiveField(1) - late int end; - - CacheTrackSkipSegment(); - - CacheTrackSkipSegment.fromJson(Map map) - : start = map["start"].toInt(), - end = map["end"].toInt(); - - Map toJson() { - return Map.castFrom( - {"start": start, "end": end}); - } -} - -@HiveType(typeId: 1) -class CacheTrack extends HiveObject { - @HiveField(0) - late String id; - - @HiveField(1) - late String title; - - @HiveField(2) - late String channelId; - - @HiveField(3) - late String? uploadDate; - - @HiveField(4) - late String? publishDate; - - @HiveField(5) - late String description; - - @HiveField(6) - late String? duration; - - @HiveField(7) - late List? keywords; - - @HiveField(8) - late CacheTrackEngagement engagement; - - @HiveField(9) - late String mode; - - @HiveField(10) - late String author; - - @HiveField(11) - late List? skipSegments; - - CacheTrack(); - - CacheTrack.fromVideo( - Video video, - this.mode, { - required List> skipSegments, - }) : id = video.id.value, - title = video.title, - author = video.author, - channelId = video.channelId.value, - uploadDate = video.uploadDate.toString(), - publishDate = video.publishDate.toString(), - description = video.description, - duration = video.duration.toString(), - keywords = video.keywords, - engagement = CacheTrackEngagement.fromEngagement(video.engagement), - skipSegments = skipSegments - .map((segment) => CacheTrackSkipSegment.fromJson(segment)) - .toList(); -} diff --git a/lib/entities/cache_track.g.dart b/lib/entities/cache_track.g.dart deleted file mode 100644 index b04ef5551..000000000 --- a/lib/entities/cache_track.g.dart +++ /dev/null @@ -1,148 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'cache_track.dart'; - -// ************************************************************************** -// TypeAdapterGenerator -// ************************************************************************** - -class CacheTrackEngagementAdapter extends TypeAdapter { - @override - final int typeId = 2; - - @override - CacheTrackEngagement read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return CacheTrackEngagement() - ..viewCount = fields[0] as int - ..likeCount = fields[1] as int? - ..dislikeCount = fields[2] as int?; - } - - @override - void write(BinaryWriter writer, CacheTrackEngagement obj) { - writer - ..writeByte(3) - ..writeByte(0) - ..write(obj.viewCount) - ..writeByte(1) - ..write(obj.likeCount) - ..writeByte(2) - ..write(obj.dislikeCount); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is CacheTrackEngagementAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} - -class CacheTrackSkipSegmentAdapter extends TypeAdapter { - @override - final int typeId = 3; - - @override - CacheTrackSkipSegment read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return CacheTrackSkipSegment() - ..start = fields[0] as int - ..end = fields[1] as int; - } - - @override - void write(BinaryWriter writer, CacheTrackSkipSegment obj) { - writer - ..writeByte(2) - ..writeByte(0) - ..write(obj.start) - ..writeByte(1) - ..write(obj.end); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is CacheTrackSkipSegmentAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} - -class CacheTrackAdapter extends TypeAdapter { - @override - final int typeId = 1; - - @override - CacheTrack read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return CacheTrack() - ..id = fields[0] as String - ..title = fields[1] as String - ..channelId = fields[2] as String - ..uploadDate = fields[3] as String? - ..publishDate = fields[4] as String? - ..description = fields[5] as String - ..duration = fields[6] as String? - ..keywords = (fields[7] as List?)?.cast() - ..engagement = fields[8] as CacheTrackEngagement - ..mode = fields[9] as String - ..author = fields[10] as String - ..skipSegments = (fields[11] as List?)?.cast(); - } - - @override - void write(BinaryWriter writer, CacheTrack obj) { - writer - ..writeByte(12) - ..writeByte(0) - ..write(obj.id) - ..writeByte(1) - ..write(obj.title) - ..writeByte(2) - ..write(obj.channelId) - ..writeByte(3) - ..write(obj.uploadDate) - ..writeByte(4) - ..write(obj.publishDate) - ..writeByte(5) - ..write(obj.description) - ..writeByte(6) - ..write(obj.duration) - ..writeByte(7) - ..write(obj.keywords) - ..writeByte(8) - ..write(obj.engagement) - ..writeByte(9) - ..write(obj.mode) - ..writeByte(10) - ..write(obj.author) - ..writeByte(11) - ..write(obj.skipSegments); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is CacheTrackAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} diff --git a/lib/extensions/piped.dart b/lib/extensions/piped.dart index 3ffdc2689..1d890f863 100644 --- a/lib/extensions/piped.dart +++ b/lib/extensions/piped.dart @@ -1,37 +1,6 @@ -import 'dart:convert'; - -import 'package:catcher/catcher.dart'; -import 'package:http/http.dart'; import 'package:piped_client/piped_client.dart'; -import 'package:spotube/entities/cache_track.dart'; -import 'package:spotube/models/logger.dart'; import 'package:spotube/models/track.dart'; -import 'package:spotube/provider/user_preferences_provider.dart'; import 'package:spotube/services/youtube.dart'; -import 'package:spotube/utils/duration.dart'; - -extension PipedSearchItemExtension on PipedSearchItem { - static PipedSearchItemStream fromCacheTrack(CacheTrack cacheTrack) { - return PipedSearchItemStream( - type: PipedSearchItemType.stream, - url: "watch?v=${cacheTrack.id}", - title: cacheTrack.title, - uploaderName: cacheTrack.author, - uploaderUrl: "/channel/${cacheTrack.channelId}", - uploaded: -1, - uploadedDate: cacheTrack.uploadDate ?? "", - shortDescription: cacheTrack.description, - isShort: false, - thumbnail: "", - duration: cacheTrack.duration != null - ? tryParseDuration(cacheTrack.duration!) ?? Duration.zero - : Duration.zero, - uploaderAvatar: "", - uploaderVerified: false, - views: cacheTrack.engagement.viewCount, - ); - } -} extension PipedStreamResponseExtension on PipedStreamResponse { static Future fromBackendTrack( diff --git a/lib/extensions/video.dart b/lib/extensions/video.dart deleted file mode 100644 index 81d43c87a..000000000 --- a/lib/extensions/video.dart +++ /dev/null @@ -1,159 +0,0 @@ -import 'dart:convert'; - -import 'package:catcher/catcher.dart'; -import 'package:http/http.dart'; -import 'package:spotube/entities/cache_track.dart'; -import 'package:spotube/models/logger.dart'; -import 'package:spotube/models/track.dart'; -import 'package:spotube/provider/user_preferences_provider.dart'; -import 'package:spotube/utils/duration.dart'; -import 'package:youtube_explode_dart/youtube_explode_dart.dart'; - -extension VideoFromCacheTrackExtension on Video { - static Video fromCacheTrack(CacheTrack cacheTrack) { - return Video( - VideoId.fromString(cacheTrack.id), - cacheTrack.title, - cacheTrack.author, - ChannelId.fromString(cacheTrack.channelId), - cacheTrack.uploadDate != null - ? DateTime.tryParse(cacheTrack.uploadDate!) - : null, - cacheTrack.uploadDate, - cacheTrack.publishDate != null - ? DateTime.tryParse(cacheTrack.publishDate!) - : null, - cacheTrack.description, - cacheTrack.duration != null - ? tryParseDuration(cacheTrack.duration!) - : null, - ThumbnailSet(cacheTrack.id), - cacheTrack.keywords, - Engagement( - cacheTrack.engagement.viewCount, - cacheTrack.engagement.likeCount, - cacheTrack.engagement.dislikeCount, - ), - false, - ); - } - - static Future