get static method

Implementation

static Future<List<DGDirectLinkModel>> get(String url) async {
  final List<DGDirectLinkModel> links = [];
  await DGHubWebScrapper.get(url, header: {"User-agent": Tools.windowAgent})
      .then((value) {
    try {
      String? sc1 = RegExp("al_video.php', ?(\\{.*])", multiLine: true)
          .firstMatch(value!.body!.text.toString())!
          .group(1);
      String? sc2 = RegExp("\\}, ?(.*)", multiLine: true)
          .firstMatch(sc1.toString())!
          .group(1);
      String x240 = "url240",
          x360 = "url360",
          x480 = "url480",
          x720 = "url720",
          x1080 = "url1080";

      var decode = jsonDecode(sc2!);
      var getLink = decode[4]['player']['params'][0];

      try {
        links.add(DGDirectLinkModel(
            quality: '240P', link: getLink[x240].toString().trim()));
        if (kDebugMode) {
          print(getLink[x240].toString());
        }
      } catch (e) {
        if (kDebugMode) {
          print(e);
        }
      }
      try {
        links.add(DGDirectLinkModel(
            quality: '360P', link: getLink[x360].toString().trim()));
        if (kDebugMode) {
          print(getLink[x360].toString());
        }
      } catch (e) {
        if (kDebugMode) {
          print(e);
        }
      }

      try {
        links.add(DGDirectLinkModel(
            quality: '480P', link: getLink[x480].toString().trim()));
        if (kDebugMode) {
          print(getLink[x480].toString());
        }
      } catch (e) {
        if (kDebugMode) {
          print(e);
        }
      }
      try {
        links.add(DGDirectLinkModel(
            quality: '720P', link: getLink[x720].toString().trim()));
      } catch (e) {
        if (kDebugMode) {
          print(e);
        }
      }
      try {
        links.add(DGDirectLinkModel(
            quality: '1080P', link: getLink[x1080].toString().trim()));
      } catch (e) {
        if (kDebugMode) {
          print(e);
        }
      }
    } catch (e) {
      if (kDebugMode) {
        print(e.toString());
      }
    }
  }).onError((error, stackTrace) {
    if (kDebugMode) {
      print(error.toString());
      print(stackTrace.toString());
    }
  });

  return links;
}