Skip to content

Commit bbcb910

Browse files
committed
Fix some urls and improve srt parsing
1 parent c9c5023 commit bbcb910

6 files changed

Lines changed: 71 additions & 54 deletions

File tree

android/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pluginManagement {
1818

1919
plugins {
2020
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
21-
id("com.android.application") version "8.7.3" apply false
21+
id("com.android.application") version "8.9.1" apply false
2222
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
2323
}
2424

lib/app.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
378378
}
379379
if (clipboardText.endsWith('.ts')) {
380380
url = clipboardText.replaceAll('240.mp4', '1080.mp4');
381+
url = clipboardText.replaceAll('360.mp4', '1080.mp4');
381382
// `1080.mp4:hls:seg-123-v1-a1.ts` => `1080.mp4:hls:manifest.m3u8`
382383
url = url.replaceAll(RegExp(r'seg-[^:]+\.ts$'), 'manifest.m3u8');
383384
}

lib/models/app.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ class AppModel extends ChangeNotifier {
525525
if (!data.item.url.startsWith('http')) {
526526
data.item.url = 'http://${data.item.url}';
527527
}
528+
data.item.url = Uri.encodeFull(data.item.url);
528529
final url = data.item.url;
529530
if (url.contains('youtube.com/playlist')) {
530531
sendYoutubePlaylist(data);

lib/models/player.dart

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,13 @@ class PlayerModel extends ChangeNotifier {
333333
}
334334
var subsUrl = item.subs ?? '';
335335
if (subsUrl.isEmpty) return null;
336+
if (subsUrl.startsWith('/')) {
337+
final relativeHost = app.getChannelLink();
338+
subsUrl = '$relativeHost${subsUrl}';
339+
}
336340
if (!subsUrl.startsWith('http')) {
337341
subsUrl = 'http://$subsUrl';
338342
}
339-
// if (subsUrl == '') {
340-
// if (item.duration < 60 * 5) return null;
341-
// final i = item.url.lastIndexOf('.mp4');
342-
// if (i == -1) return null;
343-
// subsUrl = item.url.replaceFirst('.mp4', '.ass', i);
344-
// }
345343
return compute(_loadCaptionsFuture, subsUrl);
346344
}
347345

@@ -382,19 +380,36 @@ class PlayerModel extends ChangeNotifier {
382380
final lines = text.replaceAll('\r\n', '\n').split('\n');
383381
final blocks = getSrtBlocks(lines);
384382
final badTimeReg = RegExp(r'(,[\d]+)');
383+
385384
for (final lines in blocks) {
386385
if (lines.length < 3) continue;
387386
final textLines = lines.getRange(2, lines.length).toList();
388387
final time = lines[1].replaceAllMapped(badTimeReg, (match) {
389388
final ms = match.group(1)!;
390389
return ms.length < 4 ? ms.padRight(4, '0') : ms;
391390
});
392-
subs.add({
393-
'counter': lines[0],
394-
'time': time.replaceAll(',', '.'),
395-
'text': textLines.join('\n').trim(),
396-
});
391+
final normalizedTime = time.replaceAll(',', '.');
392+
393+
// find last index that has different timing. will be `length - 1` element most of the time
394+
final lastDifferentTimeI = subs.lastIndexWhere(
395+
(sub) => sub['time'] != normalizedTime,
396+
);
397+
final i = lastDifferentTimeI + 1;
398+
399+
final text = textLines.join('\n').trim();
400+
if (i < subs.length) {
401+
// Merge text with existing subtitle (add at top like in web case)
402+
subs[i]['text'] = '$text\n${subs[i]['text']}';
403+
} else {
404+
// Add new subtitle
405+
subs.add({
406+
'counter': lines[0],
407+
'time': normalizedTime,
408+
'text': text,
409+
});
410+
}
397411
}
412+
398413
var data = 'WEBVTT\n\n';
399414
for (final sub in subs) {
400415
data += '${sub['counter']}\n';

pubspec.lock

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ packages:
55
dependency: "direct main"
66
description:
77
name: app_links
8-
sha256: "5f88447519add627fe1cbcab4fd1da3d4fed15b9baf29f28b22535c95ecee3e8"
8+
sha256: "3462d9defc61565fde4944858b59bec5be2b9d5b05f20aed190adb3ad08a7abc"
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "6.4.1"
11+
version: "7.0.0"
1212
app_links_linux:
1313
dependency: transitive
1414
description:
@@ -93,10 +93,10 @@ packages:
9393
dependency: transitive
9494
description:
9595
name: cross_file
96-
sha256: "942a4791cd385a68ccb3b32c71c427aba508a1bb949b86dff2adbe4049f16239"
96+
sha256: "701dcfc06da0882883a2657c445103380e53e647060ad8d9dfb710c100996608"
9797
url: "https://pub.dev"
9898
source: hosted
99-
version: "0.3.5"
99+
version: "0.3.5+1"
100100
crypto:
101101
dependency: "direct main"
102102
description:
@@ -125,10 +125,10 @@ packages:
125125
dependency: "direct main"
126126
description:
127127
name: device_info_plus
128-
sha256: dd0e8e02186b2196c7848c9d394a5fd6e5b57a43a546082c5820b1ec72317e33
128+
sha256: "4df8babf73058181227e18b08e6ea3520cf5fc5d796888d33b7cb0f33f984b7c"
129129
url: "https://pub.dev"
130130
source: hosted
131-
version: "12.2.0"
131+
version: "12.3.0"
132132
device_info_plus_platform_interface:
133133
dependency: transitive
134134
description:
@@ -165,10 +165,10 @@ packages:
165165
dependency: "direct main"
166166
description:
167167
name: file_picker
168-
sha256: f8f4ea435f791ab1f817b4e338ed958cb3d04ba43d6736ffc39958d950754967
168+
sha256: "57d9a1dd5063f85fa3107fb42d1faffda52fdc948cefd5fe5ea85267a5fc7343"
169169
url: "https://pub.dev"
170170
source: hosted
171-
version: "10.3.6"
171+
version: "10.3.10"
172172
flutter:
173173
dependency: "direct main"
174174
description: flutter
@@ -178,10 +178,10 @@ packages:
178178
dependency: transitive
179179
description:
180180
name: flutter_plugin_android_lifecycle
181-
sha256: "306f0596590e077338312f38837f595c04f28d6cdeeac392d3d74df2f0003687"
181+
sha256: ee8068e0e1cd16c4a82714119918efdeed33b3ba7772c54b5d094ab53f9b7fd1
182182
url: "https://pub.dev"
183183
source: hosted
184-
version: "2.0.32"
184+
version: "2.0.33"
185185
flutter_test:
186186
dependency: "direct dev"
187187
description: flutter
@@ -300,10 +300,10 @@ packages:
300300
dependency: "direct main"
301301
description:
302302
name: native_device_orientation
303-
sha256: bc0bcccc79752048d2235c10545c5fd554a46035fe0a4a4534d1bb9d8bc85e6c
303+
sha256: "711aabfd7c67396f6562437cba078d17291f8b7c454c2fbc9739c9d7141b041d"
304304
url: "https://pub.dev"
305305
source: hosted
306-
version: "2.0.4"
306+
version: "2.1.0"
307307
nested:
308308
dependency: transitive
309309
description:
@@ -316,10 +316,10 @@ packages:
316316
dependency: "direct main"
317317
description:
318318
name: ota_update
319-
sha256: e0872d082b9498f543a9b51f25001e2c77e5e3963abdc36e7c849606a283d287
319+
sha256: "1f4c7c3c4f306729a6c00b84435096ce2d8b28439013f7237173acc699b2abc8"
320320
url: "https://pub.dev"
321321
source: hosted
322-
version: "7.0.2"
322+
version: "7.1.0"
323323
package_info_plus:
324324
dependency: "direct main"
325325
description:
@@ -412,26 +412,26 @@ packages:
412412
dependency: "direct main"
413413
description:
414414
name: shared_preferences
415-
sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5"
415+
sha256: "2939ae520c9024cb197fc20dee269cd8cdbf564c8b5746374ec6cacdc5169e64"
416416
url: "https://pub.dev"
417417
source: hosted
418-
version: "2.5.3"
418+
version: "2.5.4"
419419
shared_preferences_android:
420420
dependency: transitive
421421
description:
422422
name: shared_preferences_android
423-
sha256: "34266009473bf71d748912da4bf62d439185226c03e01e2d9687bc65bbfcb713"
423+
sha256: "83af5c682796c0f7719c2bbf74792d113e40ae97981b8f266fa84574573556bc"
424424
url: "https://pub.dev"
425425
source: hosted
426-
version: "2.4.15"
426+
version: "2.4.18"
427427
shared_preferences_foundation:
428428
dependency: transitive
429429
description:
430430
name: shared_preferences_foundation
431-
sha256: "1c33a907142607c40a7542768ec9badfd16293bac51da3a4482623d15845f88b"
431+
sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f"
432432
url: "https://pub.dev"
433433
source: hosted
434-
version: "2.5.5"
434+
version: "2.5.6"
435435
shared_preferences_linux:
436436
dependency: transitive
437437
description:
@@ -553,34 +553,34 @@ packages:
553553
dependency: transitive
554554
description:
555555
name: url_launcher_android
556-
sha256: "5c8b6c2d89a78f5a1cca70a73d9d5f86c701b36b42f9c9dac7bad592113c28e9"
556+
sha256: "767344bf3063897b5cf0db830e94f904528e6dd50a6dfaf839f0abf509009611"
557557
url: "https://pub.dev"
558558
source: hosted
559-
version: "6.3.24"
559+
version: "6.3.28"
560560
url_launcher_ios:
561561
dependency: transitive
562562
description:
563563
name: url_launcher_ios
564-
sha256: "6b63f1441e4f653ae799166a72b50b1767321ecc263a57aadf825a7a2a5477d9"
564+
sha256: cfde38aa257dae62ffe79c87fab20165dfdf6988c1d31b58ebf59b9106062aad
565565
url: "https://pub.dev"
566566
source: hosted
567-
version: "6.3.5"
567+
version: "6.3.6"
568568
url_launcher_linux:
569569
dependency: transitive
570570
description:
571571
name: url_launcher_linux
572-
sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935"
572+
sha256: d5e14138b3bc193a0f63c10a53c94b91d399df0512b1f29b94a043db7482384a
573573
url: "https://pub.dev"
574574
source: hosted
575-
version: "3.2.1"
575+
version: "3.2.2"
576576
url_launcher_macos:
577577
dependency: transitive
578578
description:
579579
name: url_launcher_macos
580-
sha256: "8262208506252a3ed4ff5c0dc1e973d2c0e0ef337d0a074d35634da5d44397c9"
580+
sha256: "368adf46f71ad3c21b8f06614adb38346f193f3a59ba8fe9a2fd74133070ba18"
581581
url: "https://pub.dev"
582582
source: hosted
583-
version: "3.2.4"
583+
version: "3.2.5"
584584
url_launcher_platform_interface:
585585
dependency: transitive
586586
description:
@@ -601,10 +601,10 @@ packages:
601601
dependency: transitive
602602
description:
603603
name: url_launcher_windows
604-
sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77"
604+
sha256: "712c70ab1b99744ff066053cbe3e80c73332b38d46e5e945c98689b2e66fc15f"
605605
url: "https://pub.dev"
606606
source: hosted
607-
version: "3.1.4"
607+
version: "3.1.5"
608608
vector_math:
609609
dependency: transitive
610610
description:
@@ -625,18 +625,18 @@ packages:
625625
dependency: transitive
626626
description:
627627
name: video_player_android
628-
sha256: cf768d02924b91e333e2bc1ff928528f57d686445874f383bafab12d0bdfc340
628+
sha256: ee4fd520b0cafa02e4a867a0f882092e727cdaa1a2d24762171e787f8a502b0a
629629
url: "https://pub.dev"
630630
source: hosted
631-
version: "2.8.17"
631+
version: "2.9.1"
632632
video_player_avfoundation:
633633
dependency: transitive
634634
description:
635635
name: video_player_avfoundation
636-
sha256: "03fc6d07dba2499588d30887329b399c1fe2d68ce4b7fcff0db79f44a2603f69"
636+
sha256: e4d33b79a064498c6eb3a6a492b6a5012573d4943c28d566caf1a6c0840fe78d
637637
url: "https://pub.dev"
638638
source: hosted
639-
version: "2.8.6"
639+
version: "2.8.8"
640640
video_player_platform_interface:
641641
dependency: transitive
642642
description:
@@ -737,10 +737,10 @@ packages:
737737
dependency: "direct main"
738738
description:
739739
name: youtube_explode_dart
740-
sha256: "947ba05e0c4f050743e480e7bca3575ff6427d86cc898c1a69f5e1d188cdc9e0"
740+
sha256: "3d731d71df9901b1915bae806781df519cff32517e36db279f844ae619669e45"
741741
url: "https://pub.dev"
742742
source: hosted
743-
version: "2.5.3"
743+
version: "3.0.5"
744744
sdks:
745-
dart: ">=3.9.0 <4.0.0"
746-
flutter: ">=3.35.0"
745+
dart: ">=3.10.0 <4.0.0"
746+
flutter: ">=3.38.1"

pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1515
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1616
# Read more about iOS versioning at
1717
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18-
version: 1.0.0+32
18+
version: 1.0.0+34
1919

2020
environment:
2121
sdk: ^3.9.0
@@ -40,7 +40,7 @@ dependencies:
4040

4141
http: ^1.6.0
4242

43-
youtube_explode_dart: ^2.5.3
43+
youtube_explode_dart: ^3.0.5
4444

4545
url_launcher: ^6.3.2
4646

@@ -52,11 +52,11 @@ dependencies:
5252

5353
package_info_plus: ^9.0.0
5454

55-
app_links: ^6.4.0
55+
app_links: ^7.0.0
5656

5757
ota_update: ^7.0.2
5858

59-
file_picker: ^10.3.6
59+
file_picker: ^10.3.10
6060

6161
# The following adds the Cupertino Icons font to your application.
6262
# Use with the CupertinoIcons class for iOS style icons.

0 commit comments

Comments
 (0)