mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-06-02 11:26:18 +02:00
move to background thread
This commit is contained in:
parent
b3a9980d86
commit
b56b758a16
|
@ -1,9 +1,9 @@
|
|||
package app.revanced;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.StrictMode;
|
||||
import androidx.annotation.Nullable;
|
||||
import app.revanced.integrations.shared.Logger;
|
||||
import app.revanced.integrations.shared.Utils;
|
||||
import app.revanced.integrations.youtube.requests.Requester;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||
|
@ -78,12 +78,10 @@ public class Test {
|
|||
|
||||
if (!s.contains("googlevideo")) return s;
|
||||
if (formats == null) {
|
||||
var f = new HashMap<Integer, String>();
|
||||
Logger.printInfo(() -> "Hooked start");
|
||||
try {
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
|
||||
formats = Utils.submitOnBackgroundThread(() -> {
|
||||
var f = new HashMap<Integer, String>();
|
||||
NewPipe.init(new Downloader() {
|
||||
@Override
|
||||
public Response execute(Request request) throws IOException {
|
||||
|
@ -130,10 +128,11 @@ public class Test {
|
|||
for (VideoStream videoStream : extractor.getVideoStreams()) {
|
||||
f.put(videoStream.getItag(), videoStream.getContent());
|
||||
}
|
||||
|
||||
formats = f;
|
||||
Logger.printInfo(() -> "Hooked got format");
|
||||
|
||||
return f;
|
||||
}).get();
|
||||
|
||||
} catch (Exception i) {
|
||||
Logger.printInfo(() -> "Hooked Error making request: " + i.getMessage(), i);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user