diff --git a/lib/pages/episode-detail.dart b/lib/pages/episode-detail.dart index 4a743ce..8eb7805 100644 --- a/lib/pages/episode-detail.dart +++ b/lib/pages/episode-detail.dart @@ -58,6 +58,8 @@ class _EpisodeDetailState extends State { return Text(error.toString()); }, renderSuccess: ({data}) { + var currentServer = data['stream_url'][0]; + var currentServerName = data['stream_name'][0]; return Center( child: ListView( children: [ @@ -65,7 +67,7 @@ class _EpisodeDetailState extends State { height: 200, child: Center( child: InAppWebView( - initialUrl: data['stream_url'][0], + initialUrl: currentServer, onWebViewCreated: (InAppWebViewController controller) { webView = controller; @@ -76,6 +78,44 @@ class _EpisodeDetailState extends State { ), ), ), + Card( + child: Row( + children: [ + Flexible( + flex: 3, + child: Container( + alignment: Alignment.centerRight, + margin: EdgeInsets.all(10), + child: Text('Select Server', style: TextStyle(fontSize: 20),), + ), + ), + Flexible( + flex: 3, + child: Container( + alignment: Alignment.centerLeft, + margin: EdgeInsets.all(10), + child: DropdownButton( + value: currentServerName, + onChanged: (newValue){ + setState(() { + int index = data['stream_name'].indexOf(newValue); + currentServer = data['stream_url'][index]; + currentServerName = data['stream_name'][index]; + }); + }, + items: data['stream_name'].map>((String value) { + return DropdownMenuItem( + child: Text(value), + value: value, + ); + }).toList(), + ), + // child: Text('test'), + ), + ) + ], + ), + ), Card( child: Container( margin: EdgeInsets.all(10), diff --git a/lib/scrapper/new-release.dart b/lib/scrapper/new-release.dart index 03ceb23..5b2b4c8 100644 --- a/lib/scrapper/new-release.dart +++ b/lib/scrapper/new-release.dart @@ -44,6 +44,7 @@ Future getNewRelease(String page) async { Future getEpisodeDetail(String url) async { try { List streamUrls = []; + List streamNames = []; List downloadUrls = []; List description = []; final response = await http.get(url); @@ -51,6 +52,9 @@ Future getEpisodeDetail(String url) async { document.getElementsByTagName('iframe').forEach((x) { streamUrls.add(x.attributes['data-src']); }); + document.getElementsByClassName('change-player').forEach((x) { + streamNames.add(x.text); + }); var downloadBox = document.getElementsByClassName('linkstv')[0]; downloadBox.getElementsByTagName('a').forEach((x) { downloadUrls.add(x.attributes['href']); @@ -63,6 +67,9 @@ Future getEpisodeDetail(String url) async { contentBox.getElementsByTagName('p').forEach((x) { description.add(x.text); }); + if (streamUrls.length != streamNames.length) { + streamNames = streamNames.sublist(0, streamUrls.length); + } var rmv = title.split(' Episode '); title = rmv[0].replaceAll('Sinopsis dari anime ', ''); final data = { @@ -70,6 +77,7 @@ Future getEpisodeDetail(String url) async { 'description': description.join('\n\n'), 'image': image.replaceAll(new RegExp(r'\/w(\d\d\d)\/'), '/original/'), 'detail_url': detailUrl, + 'stream_name': streamNames, 'stream_url': streamUrls, 'download_url': downloadUrls };