get static method

Implementation

static Future<List<DGDirectLinkModel>> get(String url) 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 DGHubWebScrapper.get(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 (kDebugMode) {
        print(e.toString());
      }
    }
  }).onError((error, stackTrace) {
    if (kDebugMode) {
      print(error.toString());
      print(stackTrace.toString());
    }
  });

  return links;
}