Skip to content

Commit 0a28222

Browse files
committed
altyazı çekme eklendi
1 parent 6d8cff0 commit 0a28222

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

anitr-cli.cpp

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ int main(int argc, char* argv[]) {
387387

388388
// Bölüm URL'si ile izleme URL'sini al
389389
std::vector<std::map<std::string, std::string>> watch_url = fetchdata.fetch_anime_watch_api_url(episode_url);
390-
391390
if (!watch_url.empty())
392391
{
393392
// URL'yi al
@@ -397,8 +396,15 @@ int main(int argc, char* argv[]) {
397396
// MPV ile izleme başlat
398397
std::cout << "İzleniyor: " << selected_anime_name << " " << anime_episodes[selected_episode_index].at("name") << "\n";
399398
// std::cout << video_url << "\n";
400-
std::string mpv_cmd = "mpv --fullscreen " + video_url + " > /dev/null 2>&1";
401-
system(mpv_cmd.c_str());
399+
400+
std::string subtitle_url = watch_url[0]["subtitle"];
401+
if (subtitle_url != "No Subtitle") {
402+
std::string command = "mpv --fullscreen \"" + video_url + "\" --sub-file=\"" + subtitle_url + "\" > /dev/null 2>&1";
403+
system(command.c_str()); // MPV'yi altyazıyla başlat
404+
} else {
405+
std::string command = "mpv --fullscreen \"" + video_url + "\" > /dev/null 2>&1";
406+
system(command.c_str()); // MPV'yi altyazısız başlat
407+
}
402408
}
403409

404410
else
@@ -441,8 +447,17 @@ int main(int argc, char* argv[]) {
441447

442448
// MPV ile izleme başlat
443449
std::cout << "İzleniyor: " << selected_anime_name << " " << anime_episodes[selected_episode_index].at("name") << "\n";
444-
std::string mpv_cmd = "mpv --fullscreen " + video_url + " > /dev/null 2>&1";
445-
system(mpv_cmd.c_str());
450+
451+
std::string subtitle_url = watch_url[0]["subtitle"];
452+
453+
if (subtitle_url != "No Subtitle") {
454+
std::string command = "mpv --fullscreen \"" + video_url + "\" --sub-file=\"" + subtitle_url + "\" > /dev/null 2>&1";
455+
system(command.c_str()); // MPV'yi altyazıyla başlat
456+
} else {
457+
std::string command = "mpv --fullscreen \"" + video_url + "\" > /dev/null 2>&1";
458+
system(command.c_str()); // MPV'yi altyazısız başlat
459+
}
460+
446461

447462
}
448463

@@ -468,8 +483,17 @@ int main(int argc, char* argv[]) {
468483

469484
// MPV ile izleme başlat
470485
std::cout << "İzleniyor: " << selected_anime_name << " " << anime_episodes[selected_episode_index].at("name") << "\n";
471-
std::string mpv_cmd = "mpv --fullscreen " + video_url + " > /dev/null 2>&1";
472-
system(mpv_cmd.c_str());
486+
487+
std::string subtitle_url = watch_url[0]["subtitle"];
488+
489+
if (subtitle_url != "No Subtitle") {
490+
std::string command = "mpv --fullscreen \"" + video_url + "\" --sub-file=\"" + subtitle_url + "\" > /dev/null 2>&1";
491+
system(command.c_str()); // MPV'yi altyazıyla başlat
492+
} else {
493+
std::string command = "mpv --fullscreen \"" + video_url + "\" > /dev/null 2>&1";
494+
system(command.c_str()); // MPV'yi altyazısız başlat
495+
}
496+
473497

474498
}
475499

modules/anitr_fetch.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ std::vector<std::map<std::string, std::string>> FetchData::fetch_anime_watch_api
219219
}
220220
}
221221

222-
std::string apiUrl = "https://tau-video.xyz/api/video/" + embed_id + "?vid=" + vid_value;
222+
std::string apiUrl = "https://tau-video.xyz/api/video/" + embed_id;
223223
std::vector<std::map<std::string, std::string>> urls;
224224

225225
CURL* curl = curl_easy_init();
@@ -241,10 +241,25 @@ std::vector<std::map<std::string, std::string>> FetchData::fetch_anime_watch_api
241241
// JSON verisini işlemek için nlohmann/json kütüphanesini kullanıyoruz
242242
try {
243243
nlohmann::json json_response = nlohmann::json::parse(response_string);
244+
245+
std::string subtitle_url = "No Subtitle"; // Varsayılan değer
246+
247+
if (json_response.contains("subs")) {
248+
for (const auto& subtitle : json_response["subs"]) {
249+
// Her bir altyazı için 'url' değerini al
250+
subtitle_url = subtitle.value("url", "No Subtitle URL");
251+
// İhtiyaç duyarsanız başka işlemler de ekleyebilirsiniz
252+
}
253+
} else {
254+
std::cerr << "'subs' dizisi boş veya eksik!" << std::endl;
255+
}
256+
244257
for (const auto& item : json_response["urls"]) {
245258
std::map<std::string, std::string> urlData;
246259
urlData["url"] = item.value("url", "No URL field");
247260
urlData["quality"] = item.value("label", "Unknown");
261+
urlData["subtitle"] = subtitle_url; // Altyazı linkini ekle
262+
248263
urls.push_back(urlData);
249264
}
250265
} catch (const nlohmann::json::parse_error& e) {

0 commit comments

Comments
 (0)