Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Export favorites to JSON #75

Closed
ghost opened this issue Nov 3, 2022 · 4 comments
Closed

Feature request: Export favorites to JSON #75

ghost opened this issue Nov 3, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Nov 3, 2022

Really like the app so far. I'm interested in exporting my (locally-saved) favorites to JSON. In particular, this would be useful for searching when I'm on my PC and need something.

@Mosc Mosc added the enhancement New feature or request label Nov 6, 2022
@pm4rcin
Copy link

pm4rcin commented Dec 3, 2022

Or export in any other way because I'm not logged in and I have dozens of favorites and exporting it one by one is a tedious process.

@ThomasChevalier
Copy link

I needed this feature as well and wrote this little script to export favorites using adb. Dependencies : java, xmllint, adb

Probably not the cleanest solution but it worked well to export all my locally saved posts.

#!/bin/bash

# Connect to your phone using adb
adb start-server
# The following command must show your phone connected for the script to work
adb devices

# Get the Glider package name
package_name=$(adb shell cmd package list packages | grep -i glider | sed -e 's/^package://')
# nl.viter.glider

# Backup application data
adb backup -noapk -f backup.ab "${package_name}"

# Download latest version of android-backup-extractor (abe.jar)
wget https://github.com/nelenkov/android-backup-extractor/releases/download/master-20221109063121-8fdfc5e/abe.jar

# Extract backup using the backup password previously entered on the phone
read -s -p "Backup password: " password
java -jar abe.jar unpack backup.ab output.tar "$password"
tar -xvf output.tar

# Get the 'flutter.favorited' key and decode it
# The string 'This is the prefix for a list.' is appended before, we need to remove it
xmllint apps/nl.viter.glider/sp/FlutterSharedPreferences.xml --xpath "/map/string[@name='flutter.favorited']/text()" | head -n -1 | base64 -d | sed -e 's/^This is the prefix for a list.//' > favorited.serialized

# Write a small java app to parse the serialized ArrayList<String>
cat >Deserialize.java << EOF
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;

public class Deserialize {
  public static void main(String[] args) {
    ArrayList<String> list = null;

    try (FileInputStream fis = new FileInputStream(args[0]);
        ObjectInputStream ois = new ObjectInputStream(fis);) {

      list = (ArrayList) ois.readObject();
    } catch (IOException ioe) {
      ioe.printStackTrace();
    } catch (ClassNotFoundException c) {
      System.out.println("Class not found");
      c.printStackTrace();
    }

    for (String name : list) {
      System.out.println("https://news.ycombinator.com/item?id=" + name);
    }
  }
}
EOF
javac Deserialize.java
java Deserialize favorited.serialized

# output:
# https://news.ycombinator.com/item?id=ABC
# https://news.ycombinator.com/item?id=XYZ
# ...

@ghost
Copy link
Author

ghost commented May 31, 2023

Hey @ThomasChevalier thanks for the script. I'm sure some people will find it useful. However, it's worth noting that the script won't work on Android 12, due to adb backup silently failing when targetSDK>=31 (Glider is using targetSDK 33). See this Android StackExchange answer: https://android.stackexchange.com/questions/231235/does-adb-backup-restore-still-work-because-it-says-its-deprecated

It would be great if @Mosc had the time to revisit this and at least implement a provisory solution based on POST requests at the very least. Then one could set up a HTTP server and intercept/save accordingly.

@Mosc
Copy link
Owner

Mosc commented Oct 23, 2023

This has been implemented as part of v2.0.0! It's available on the setting page and exports a JSON with a list of favorites IDs.

@Mosc Mosc closed this as completed Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants