9c504d2c3d
Features: - Frontend Flutter avec thème néon cyberpunk - Backend FastAPI avec streaming YouTube - Base de données PostgreSQL + Redis - Authentification JWT complète - Recherche multi-source (DB + YouTube) - Playlists CRUD avec drag & drop - Queue management - Settings avec audio quality - Interface adaptative (Desktop + Mobile) Tech Stack: - Frontend: Flutter 3.2+, Riverpod - Backend: Python 3.11+, FastAPI - Database: PostgreSQL 15+ - Cache: Redis 7+ - Streaming: yt-dlp + FFmpeg 🚀 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
120 lines
3.1 KiB
Dart
120 lines
3.1 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
import 'artist.dart';
|
|
import 'album.dart';
|
|
|
|
/// Track entity
|
|
class Track extends Equatable {
|
|
final String id;
|
|
final String title;
|
|
final int? duration;
|
|
final int? trackNumber;
|
|
final String? imageUrl;
|
|
final String? artistId;
|
|
final String? albumId;
|
|
final Artist? artist;
|
|
final Album? album;
|
|
final String? audioUrl;
|
|
final int? playCount;
|
|
final String? youtubeId;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
|
|
const Track({
|
|
required this.id,
|
|
required this.title,
|
|
this.duration,
|
|
this.trackNumber,
|
|
this.imageUrl,
|
|
this.artistId,
|
|
this.albumId,
|
|
this.artist,
|
|
this.album,
|
|
this.audioUrl,
|
|
this.playCount,
|
|
this.youtubeId,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
});
|
|
|
|
Track copyWith({
|
|
String? id,
|
|
String? title,
|
|
int? duration,
|
|
int? trackNumber,
|
|
String? imageUrl,
|
|
String? artistId,
|
|
String? albumId,
|
|
Artist? artist,
|
|
Album? album,
|
|
String? audioUrl,
|
|
int? playCount,
|
|
String? youtubeId,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
}) {
|
|
return Track(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
duration: duration ?? this.duration,
|
|
trackNumber: trackNumber ?? this.trackNumber,
|
|
imageUrl: imageUrl ?? this.imageUrl,
|
|
artistId: artistId ?? this.artistId,
|
|
albumId: albumId ?? this.albumId,
|
|
artist: artist ?? this.artist,
|
|
album: album ?? this.album,
|
|
audioUrl: audioUrl ?? this.audioUrl,
|
|
playCount: playCount ?? this.playCount,
|
|
youtubeId: youtubeId ?? this.youtubeId,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
/// Format duration as mm:ss
|
|
String get formattedDuration {
|
|
if (duration == null) return '--:--';
|
|
final minutes = duration! ~/ 60;
|
|
final seconds = duration! % 60;
|
|
return '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}';
|
|
}
|
|
|
|
/// Create Track from JSON
|
|
factory Track.fromJson(Map<String, dynamic> json) {
|
|
return Track(
|
|
id: json['id'] as String,
|
|
title: json['title'] as String,
|
|
duration: json['duration'] as int?,
|
|
trackNumber: json['track_number'] as int?,
|
|
imageUrl: json['image_url'] as String?,
|
|
artistId: json['artist_id'] as String?,
|
|
albumId: json['album_id'] as String?,
|
|
artist: json['artist'] != null
|
|
? Artist.fromJson(json['artist'] as Map<String, dynamic>)
|
|
: null,
|
|
album: json['album'] != null
|
|
? Album.fromJson(json['album'] as Map<String, dynamic>)
|
|
: null,
|
|
audioUrl: json['audio_url'] as String?,
|
|
playCount: json['play_count'] as int?,
|
|
youtubeId: json['youtube_id'] as String?,
|
|
createdAt: json['created_at'] != null
|
|
? DateTime.parse(json['created_at'] as String)
|
|
: DateTime.now(),
|
|
updatedAt: json['updated_at'] != null
|
|
? DateTime.parse(json['updated_at'] as String)
|
|
: DateTime.now(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [
|
|
id,
|
|
title,
|
|
duration,
|
|
artistId,
|
|
albumId,
|
|
youtubeId,
|
|
];
|
|
}
|