Skip to content

Commit

Permalink
Add: stories
Browse files Browse the repository at this point in the history
  • Loading branch information
gopi2401 committed Nov 7, 2023
1 parent b9ae511 commit 90ff41d
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
41 changes: 41 additions & 0 deletions lib/Functions/insta_download.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,47 @@ class InstaDownloadController extends GetxController {
}
}

stories(String uName, String? sId) async {
try {
var url = 'https://igs.sf-converter.com/api/userInfoByUsername/$uName';
final http.Response user = await http.get(Uri.parse(url));
var userData = jsonDecode(user.body);
var userId = userData['result']['user']['pk'];
var url1 = 'https://igs.sf-converter.com/api/stories/$userId';
final http.Response stories = await http.get(Uri.parse(url1));
var storiesData = jsonDecode(stories.body);
var arr = storiesData['result'];
for (var storie in arr) {
if (storie['pk'] == sId) {
if (storie['image_versions2'] != null) {
var image = storie['image_versions2']['candidates'][0]['url'];
if (storie['video_versions'] != null) {
var video = storie['video_versions'][0]['url'];
downloadFile(image, video, 'storie_video_$sId');
} else {
downloadFile(image, image, 'storie_image_$sId');
}
}
}
}
// arr.forEach((storie) {
// if (storie['pk'] == sId) {
// if (storie['image_versions2'] != null) {
// var image = storie['image_versions2']['candidates'][0]['url'];
// if (storie['video_versions'] != null) {
// var video = storie['video_versions'][0]['url'];
// downloadFile(image, video, 'storie_video_$sId');
// } else {
// downloadFile(image, image, 'storie_image_$sId');
// }
// }
// }
// });
} catch (e) {
print(e);
}
}

postReel(data) {
if (data['require_login'] != null && data['require_login']) {
navigatorKey.currentState?.pushNamed('login');
Expand Down
6 changes: 5 additions & 1 deletion lib/Functions/story
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ static Future<InstaProfile> storyFromUrl(String userUrl) async {
}
return _profileParsed;
}
}
}

// https://igs.sf-converter.com/api/userInfoByUsername/phoenix_queen_25
// https://igs.sf-converter.com/api/stories/50839057408
// https://igs.sf-converter.com/api/highlights/50839057408
23 changes: 21 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,27 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() {
downloading = true;
});
if (reelController.text.trim().isNotEmpty) {
downloadController.downloadReal(reelController.text);
var url = reelController.text.trim();
if (url.isNotEmpty) {
final Uri uri = Uri.parse(url);
if (uri.hasAbsolutePath) {
RegExp ins = RegExp(r'instagram.com');
bool test = ins.hasMatch(url);
if (test) {
var optIon = url.split("/")[3];
if (optIon == 'p' || optIon == 'reel') {
downloadController.downloadReal(url);
} else if (optIon == 'stories') {
var data = url.split('/');
RegExp regExp = RegExp(r'^(\d+)');
var match = regExp.firstMatch(data[5]);
if (match == null) return;
downloadController.stories(data[4], match.group(0));
}
}
} else {
print('else');
}
} else {
showToast();
}
Expand Down

0 comments on commit 90ff41d

Please sign in to comment.