jellyfin_models.dart 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /// Public identity of a Jellyfin server.
  2. class JellyfinServerInfo {
  3. const JellyfinServerInfo({required this.name, required this.version});
  4. final String name;
  5. final String version;
  6. }
  7. /// A pending Quick Connect request. The code is shown to the user; the secret
  8. /// is exchanged for an access token once the user approves the device.
  9. class JellyfinQuickConnect {
  10. const JellyfinQuickConnect({required this.code, required this.secret});
  11. final String code;
  12. final String secret;
  13. }
  14. /// The signed-in Jellyfin user for this device.
  15. class JellyfinUser {
  16. const JellyfinUser({required this.id, required this.name});
  17. final String id;
  18. final String name;
  19. }
  20. /// An access token plus the user it belongs to.
  21. class JellyfinSession {
  22. const JellyfinSession({
  23. required this.accessToken,
  24. required this.userId,
  25. required this.userName,
  26. });
  27. final String accessToken;
  28. final String userId;
  29. final String userName;
  30. }
  31. /// A Jellyfin request failed. [JellyfinUnreachable] means the server could not
  32. /// be contacted at all; [JellyfinAuthException] means the saved token is no
  33. /// longer accepted.
  34. class JellyfinException implements Exception {
  35. JellyfinException(this.message);
  36. final String message;
  37. @override
  38. String toString() => message;
  39. }
  40. class JellyfinUnreachable extends JellyfinException {
  41. JellyfinUnreachable(super.message);
  42. }
  43. class JellyfinAuthException extends JellyfinException {
  44. JellyfinAuthException(super.message);
  45. }