mirror of
https://github.com/KokaKiwi/BarInsta
synced 2026-03-14 08:21:35 +00:00
post shortcode converter
This commit is contained in:
parent
bf80104b1a
commit
efb5818a65
2 changed files with 23 additions and 1 deletions
|
|
@ -10,11 +10,13 @@ import android.util.Patterns;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class TextUtils {
|
||||
// extracted from String class
|
||||
|
|
@ -106,4 +108,15 @@ public final class TextUtils {
|
|||
}
|
||||
return urls;
|
||||
}
|
||||
|
||||
// https://github.com/notslang/instagram-id-to-url-segment
|
||||
public static long shortcodeToId(final String shortcode) {
|
||||
long result = 0L;
|
||||
for (int i = 0; i < shortcode.length() && i < 11; i++){
|
||||
final char c = shortcode.charAt(i);
|
||||
final int k = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".indexOf(c);
|
||||
result = result * 64 + k;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue