Skip to content

Commit

Permalink
Merge pull request #878 from Komodo5197/redesign-android-id
Browse files Browse the repository at this point in the history
[Redesign] Switch Android client ID source.
  • Loading branch information
Chaphasilor authored Sep 14, 2024
2 parents ae83dcd + f146573 commit 2769c4d
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 130 deletions.
13 changes: 7 additions & 6 deletions lib/services/jellyfin_api.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:io' show HttpClient, Platform;

import 'package:app_set_id/app_set_id.dart';
import 'package:chopper/chopper.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:finamp/services/http_aggregate_logging_interceptor.dart';
Expand Down Expand Up @@ -331,7 +332,6 @@ abstract class JellyfinApi extends ChopperService {
)
@Get(path: "/Artists")
Future<dynamic> getArtists({

/// Specify this to localize the search to a specific item or folder. Omit
/// to use the root.
@Query("ParentId") String? parentId,
Expand Down Expand Up @@ -382,7 +382,6 @@ abstract class JellyfinApi extends ChopperService {

/// Optional. If enabled, only favorite artists will be returned.
@Query("IsFavorite") bool? isFavorite,

});

@FactoryConverter(
Expand Down Expand Up @@ -521,7 +520,8 @@ abstract class JellyfinApi extends ChopperService {
final client = ChopperClient(
client: http.IOClient(HttpClient()
..connectionTimeout = const Duration(
seconds: 10) // if we don't get a response by then, it's probably not worth it to wait any longer. this prevents the server connection test from taking too long
seconds:
10) // if we don't get a response by then, it's probably not worth it to wait any longer. this prevents the server connection test from taking too long
),
// The first part of the URL is now here
services: [
Expand Down Expand Up @@ -604,13 +604,14 @@ Future<String> getAuthHeader() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
AndroidDeviceInfo androidDeviceInfo = await deviceInfo.androidInfo;
final appSetId = await AppSetId().getIdentifier();
authHeader = '${authHeader}Device="${androidDeviceInfo.model}", ';
authHeader = '${authHeader}DeviceId="${androidDeviceInfo.id}", ';
authHeader = '${authHeader}DeviceId="$appSetId", ';
} else if (Platform.isIOS) {
IosDeviceInfo iosDeviceInfo = await deviceInfo.iosInfo;
final appSetId = await AppSetId().getIdentifier();
authHeader = '${authHeader}Device="${iosDeviceInfo.name}", ';
authHeader =
'${authHeader}DeviceId="${iosDeviceInfo.identifierForVendor}", ';
authHeader = '${authHeader}DeviceId="$appSetId", ';
} else if (Platform.isWindows) {
WindowsDeviceInfo windowsDeviceInfo = await deviceInfo.windowsInfo;
authHeader = '${authHeader}Device="${windowsDeviceInfo.computerName}", ';
Expand Down
Loading

0 comments on commit 2769c4d

Please sign in to comment.