get static method

Future<List<DGDirectLinkModel>> get(
  1. String url,
  2. bool debugMode
)

Implementation

static Future<List<DGDirectLinkModel>> get(String url,bool debugMode) async {
  final List<DGDirectLinkModel> links = [];
  String? id = RegExp("(v|f)(\\/|=)(.+)(\\/|&)?", multiLine: true)
      .firstMatch(url)!
      .group(3)!
      .replaceAll("&|/", "");

  String reUrl = "https://www.fembed.com/api/source/$id";

  await Tools.requestSite(reUrl).then((value) async {

        try {
      final response = await http.post(Uri.parse(reUrl));

      var data = jsonDecode(response.body);

      for (int i = 0; i < data['data'].length; i++) {
        links.add(DGDirectLinkModel(
            quality: data['data'][i]['label'],
            link: data['data'][i]['file']));
      }

    } catch (e) {

      if(debugMode){
 print(e.toString());
      }

    }


  }).onError((error, stackTrace) {
      if(debugMode){
 print(error.toString());
 print(stackTrace.toString());
      }
  });

 return links;
}