Email login
This commit is contained in:
parent
e809b24f5b
commit
46f3aa30da
6 changed files with 156 additions and 9 deletions
|
@ -1,3 +1,4 @@
|
|||
import 'package:crypto/crypto.dart';
|
||||
import 'package:freezer/api/definitions.dart';
|
||||
import 'package:freezer/api/spotify.dart';
|
||||
import 'package:freezer/settings.dart';
|
||||
|
@ -77,6 +78,32 @@ class DeezerAPI {
|
|||
return _authorizing;
|
||||
}
|
||||
|
||||
//Login with email
|
||||
static Future<String> getArlByEmail(String email, String password) async {
|
||||
//Get MD5 of password
|
||||
Digest digest = md5.convert(utf8.encode(password));
|
||||
String md5password = '$digest';
|
||||
//Get access token
|
||||
String url = "https://tv.deezer.com/smarttv/8caf9315c1740316053348a24d25afc7/user_auth.php?login=$email&password=$md5password&device=panasonic&output=json";
|
||||
http.Response response = await http.get(url);
|
||||
String accessToken = jsonDecode(response.body)["access_token"];
|
||||
//Get SID
|
||||
url = "https://api.deezer.com/platform/generic/track/42069";
|
||||
response = await http.get(url, headers: {"Authorization": "Bearer $accessToken"});
|
||||
String sid;
|
||||
for (String cookieHeader in response.headers['set-cookie'].split(';')) {
|
||||
if (cookieHeader.startsWith('sid=')) {
|
||||
sid = cookieHeader.split('=')[1];
|
||||
}
|
||||
}
|
||||
if (sid == null) return null;
|
||||
//Get ARL
|
||||
url = "https://deezer.com/ajax/gw-light.php?api_version=1.0&api_token=null&input=3&method=user.getArl";
|
||||
response = await http.get(url, headers: {"Cookie": "sid=$sid"});
|
||||
return jsonDecode(response.body)["results"];
|
||||
}
|
||||
|
||||
|
||||
//Authorize, bool = success
|
||||
Future<bool> rawAuthorize({Function onError}) async {
|
||||
try {
|
||||
|
@ -488,5 +515,4 @@ class DeezerAPI {
|
|||
});
|
||||
return data['results']['EPISODES']['data'].map<ShowEpisode>((e) => ShowEpisode.fromPrivateJson(e)).toList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:sqflite/sql.dart';
|
||||
import 'package:disk_space/disk_space.dart';
|
||||
import 'package:filesize/filesize.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -15,9 +15,7 @@ import 'package:permission_handler/permission_handler.dart';
|
|||
import 'package:freezer/translations.i18n.dart';
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:sqflite/sql.dart';
|
||||
import 'dart:async';
|
||||
|
||||
DownloadManager downloadManager = DownloadManager();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue