Search in sources :

Example 6 with Matcher

use of com.frostwire.regex.Matcher in project frostwire by frostwire.

the class JsFunction method extract_object.

private static JsObject extract_object(final JsContext ctx, String objname) {
    JsObject obj = new JsObject();
    String obj_mRegex = String.format("(var" + WS + "+)%1$s" + WS + "*=" + WS + "*\\{", escape(objname)) + WS + "*(?<fields>(" + VAR + WS + "*:" + WS + "*function\\(.*?\\)" + WS + "*\\{.*?\\}(," + WS + ")*)*)\\}" + WS + "*;";
    final Matcher obj_m = Pattern.compile(obj_mRegex).matcher(ctx.jscode);
    obj_m.find();
    String fields = obj_m.group("fields");
    // Currently, it only supports function definitions
    final Matcher fields_m = Pattern.compile("(?<key>" + VAR + ")" + WS + "*:" + WS + "*function\\((?<args>[a-z,]+)\\)\\" + CODE).matcher(fields);
    while (fields_m.find()) {
        final String[] argnames = mscpy(fields_m.group("args").split(","));
        LambdaN f = build_function(ctx, argnames, fields_m.group("code"));
        String field = remove_quotes(fields_m.group("key"));
        obj.functions.put(field, f);
    }
    return obj;
}
Also used : Matcher(com.frostwire.regex.Matcher)

Example 7 with Matcher

use of com.frostwire.regex.Matcher in project frostwire by frostwire.

the class YouTubeDownloadDialog method extractFormat.

private static String extractFormat(String fileName) {
    final Matcher matcher = FORMAT_PATTERN.matcher(fileName);
    String format = null;
    if (matcher.find()) {
        format = matcher.group(1).replace("_", " ").trim();
    }
    return format;
}
Also used : Matcher(com.frostwire.regex.Matcher)

Aggregations

Matcher (com.frostwire.regex.Matcher)7 SkinMenuItem (com.frostwire.gui.theme.SkinMenuItem)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1