aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-11 10:45:01 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-11 10:45:01 +0100
commitd92f6d7725720e3facf90b0fdefc1ef4eb1c2227 (patch)
tree6a4091eef23f56545431cdc0ef227efbc576b2b3 /src
parent5fb94ed3fbd0e3942632ad617f803727ecf54169 (diff)
youtube video: fix video with redirect not getting content length correctly, re-enable youtube timestamp
Diffstat (limited to 'src')
-rw-r--r--src/Downloader.cpp19
-rw-r--r--src/plugins/Youtube.cpp4
2 files changed, 14 insertions, 9 deletions
diff --git a/src/Downloader.cpp b/src/Downloader.cpp
index cb9f448..57a0349 100644
--- a/src/Downloader.cpp
+++ b/src/Downloader.cpp
@@ -310,8 +310,20 @@ namespace QuickMedia {
return offset;
}
+ static ssize_t read_eintr(int fd, void *buffer, size_t size) {
+ while(true) {
+ ssize_t bytes_read = read(fd, buffer, size);
+ if(bytes_read == -1) {
+ if(errno != EINTR)
+ return -1;
+ } else {
+ return bytes_read;
+ }
+ }
+ }
+
static int64_t read_fn(YoutubeReadProgram *program, char *buf, uint64_t nbytes) {
- ssize_t bytes_read = read(program->read_program.read_fd, buf, nbytes);
+ ssize_t bytes_read = read_eintr(program->read_program.read_fd, buf, nbytes);
if(bytes_read > 0) {
program->offset += bytes_read;
program->bytes_downloaded += bytes_read;
@@ -319,15 +331,12 @@ namespace QuickMedia {
// End of current range, progress to next range
bytes_read = seek_fn(program, program->offset);
if(bytes_read >= 0) {
- bytes_read = read(program->read_program.read_fd, buf, nbytes);
+ bytes_read = read_eintr(program->read_program.read_fd, buf, nbytes);
if(bytes_read > 0) {
program->offset += bytes_read;
program->bytes_downloaded += bytes_read;
}
}
- } else if(bytes_read < 0) {
- if(errno == EINTR || errno == EWOULDBLOCK || errno == EAGAIN)
- return 0;
}
return bytes_read;
}
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index df79701..2d92cd8 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -1860,7 +1860,6 @@ namespace QuickMedia {
}
std::string YoutubeVideoPage::get_url_timestamp() {
- #if 0
if(!timestamp.empty())
return timestamp;
@@ -1882,9 +1881,6 @@ namespace QuickMedia {
return "";
else
return std::to_string(it->second.time_pos_sec);
- #else
- return timestamp;
- #endif
}
BodyItems YoutubeVideoPage::get_related_media(const std::string &url) {