Skip to content

Commit

Permalink
Merge pull request #2 from arthurlt/fix/process_error
Browse files Browse the repository at this point in the history
remove public errors
  • Loading branch information
arthurlt authored Dec 10, 2023
2 parents 0832658 + a352f4c commit 6701b8f
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,16 @@ Future<void> processMessage(final TeleDartMessage message) async {
print(url);

// Testing if yt-dlp can process the video
// TODO: implement way to sendChatAction while processing & downloading
final io.ProcessResult simulateResult = await runYtDlp(url, simulate: true);
if (simulateResult.exitCode != 0) {
publicError(
message, 'yt-dlp failed to process $url\n${simulateResult.stderr}');
print('yt-dlp failed to process $url\n${simulateResult.stderr}');
continue;
}
// Using yt-dlp to download the video
final io.ProcessResult downloadResult = await runYtDlp(url, dir: downloadDir);
if (downloadResult.exitCode != 0) {
publicError(
message, 'yt-dlp failed to download $url\n${downloadResult.stderr}');
print('yt-dlp failed to download $url\n${downloadResult.stderr}');
continue;
}
// TODO: make sure these files exist
Expand Down Expand Up @@ -105,11 +104,6 @@ String generateCaption(final Map info) {
return caption.replaceAll(regex, '');
}

void publicError(final TeleDartMessage message, final String error) {
print('Error!! \n$error');
message.reply(error, withQuote: true, disableNotification: true);
}

// TODO: extend ProcessResult class to return some more data
Future<io.ProcessResult> runYtDlp(final String videoUrl,
{final bool simulate = false, String dir = '/tmp'}) {
Expand Down

0 comments on commit 6701b8f

Please sign in to comment.