Fixed arguments statement

This commit is contained in:
Medvidek77 2025-04-02 22:06:02 +02:00
parent c3a468d090
commit e45599e9ec
2 changed files with 12 additions and 5 deletions

View file

@ -14,9 +14,11 @@ pub fn main() !void {
const args = try std.process.argsAlloc(allocator);
defer std.process.argsFree(allocator, args);
if (eql(u8, args[1], "help")) {
dbg_print("Help :)\n", .{});
if (args.len > 1) {
if (eql(u8, args[1], "help")) {
dbg_print("Help :)\n", .{});
}
}
const data = try url.fetch(allocator, "https://tidal.401658.xyz/track/?id=286266927&quality=LOSSLESS");
@ -24,4 +26,4 @@ pub fn main() !void {
try json.extract(allocator, data);
}
}

View file

@ -1,4 +1,5 @@
const std = @import("std");
const dbg_print = std.debug.print;
@ -24,6 +25,10 @@ pub fn fetch(allocator: std.mem.Allocator, url: []const u8) ![]u8 {
const body = try req.reader().readAllAlloc(allocator, 1024 * 64);
return body;
if (req.response.status == .ok) {
return body;
}else{
return error.Unexpected;
}
}