diff options
author | sijanec <anton@sijanec.eu> | 2020-12-28 01:43:37 +0100 |
---|---|---|
committer | sijanec <anton@sijanec.eu> | 2020-12-28 01:43:37 +0100 |
commit | 70921ad87145ba42ca7c3a1b2153ebea1aad4933 (patch) | |
tree | 611586f3dcc995bc55549c91b4e1725e1ae64f9a | |
parent | naredil download v preteklost (diff) | |
download | rtv4d-dl-70921ad87145ba42ca7c3a1b2153ebea1aad4933.tar rtv4d-dl-70921ad87145ba42ca7c3a1b2153ebea1aad4933.tar.gz rtv4d-dl-70921ad87145ba42ca7c3a1b2153ebea1aad4933.tar.bz2 rtv4d-dl-70921ad87145ba42ca7c3a1b2153ebea1aad4933.tar.lz rtv4d-dl-70921ad87145ba42ca7c3a1b2153ebea1aad4933.tar.xz rtv4d-dl-70921ad87145ba42ca7c3a1b2153ebea1aad4933.tar.zst rtv4d-dl-70921ad87145ba42ca7c3a1b2153ebea1aad4933.zip |
-rw-r--r-- | README.md | 4 | ||||
-rwxr-xr-x | a.out | bin | 16712 -> 0 bytes | |||
-rwxr-xr-x | rtv4d-dl | bin | 52624 -> 52776 bytes | |||
-rw-r--r-- | rtv4d-dl.c | 75 |
4 files changed, 71 insertions, 8 deletions
@@ -25,8 +25,8 @@ z uporabo programa se strinjate z naslednjimi stavki: - opomba: nekateri metapodatki veljajo omejeno časa (video URL) * prenos sličice oddaje: `rtv4d-dl slicica-oddaja <URL> [datoteka]` - primer: `rtv4d-dl slicica-oddaja 89614963 89614963.jpg` -* prenos zadnjih dveh ur prenosa v živo: `rtv4d-dl zivo [2] [3] [4] [5]` - - primer: `rtv4d-dl zivo slo1 slo1 9999999 9999999` (prenese vse) +* prenos zadnjih dveh ur prenosa v živo: `rtv4d-dl živo [2] [3] [4] [5]` + - primer: `rtv4d-dl živo slo1 slo1 9999999 9999999` (prenese vse) - arg. 2 je program, 3 je izhodni direktorij, 4 je število sekund v preteklost, 5 je število sekund v prihodnost * prenos podnapisov oddaje: `rtv4d-dl podnapisi <url> [datoteka]` Binary files differBinary files differ@@ -9,6 +9,7 @@ #include <sys/stat.h> #include <sys/types.h> #include <errno.h> +#include <time.h> #define NIZ_DODATEK(a) #a #define NIZ(a) NIZ_DODATEK(a) #define RTV_CLIENT_ID "82013fb3a531d5414f478747c1aca622" /* enak za vse */ @@ -593,7 +594,10 @@ int main (int argc, char ** argv) { char fn[420]; /* <id>.txt / <id>.mp4 - NE USER INPUT */ char * e; /* char pointer for the memes */ FILE * fd; + FILE * fd2; unsigned int i; + time_t * casi = NULL; + time_t cas; DIR * dir; unsigned short int returnstatus = 0; switch (RTV_NACIN[0]) { @@ -773,25 +777,84 @@ int main (int argc, char ** argv) { returnstatus = 4; } for (i = z->sedanjost; i >= 0; i--) { - snprintf(fn, sizeof(fn), "%s/%u%s", - e, i, strrchr(z->kos_format, '.')); /* printf je NULL safe */ + casi = realloc(casi, sizeof(time_t)*i+1); /* NE GOTO PRED SPROŠČENJEM */ + cas = time(NULL); + casi[i] = cas; + if ((z->prenesenih_kosov_preteklost)*(z->dolzina) >= z->preteklost) { + i++; + RTV_NAPISI(INFO, "končal preteklost: kosov: %u, sekund: %u.", + z->prenesenih_kosov_preteklost, + (z->prenesenih_kosov_preteklost)*(z->dolzina)); + break; + } + snprintf(fn, sizeof(fn), "%s/%u-%lu%s", + e, i, cas, strrchr(z->kos_format, '.')); /* printf je NULL safe */ fd = fopen(fn, "w"); snprintf(fn, sizeof(fn), z->kos_format, i); if (!RTV_HTTP_SUCCESS(http_get(fn, fd))) { /* napaka je verjetno 404 */ - i--; + i++; RTV_NAPISI(INFO, "ni več kosov v preteklosti"); fclose(fd); + snprintf(fn, sizeof(fn), "%s/%u-%lu%s", + e, i, cas, strrchr(z->kos_format, '.')); + unlink(fn); break; } RTV_NAPISI(INFO, "prenesel kos %u iz preteklosti", i); fclose(fd); + z->prenesenih_kosov_preteklost++; } snprintf(fn, sizeof(fn), "%s/seznam_predvajanja.m3u8", e); - fd = fopen(fn, "w"); - fprintf(fd, "# generirano z rtv4d-dl " RTV_VER "\n"); + fd2 = fopen(fn, "w"); + fprintf(fd2, "# generirano z rtv4d-dl " RTV_VER "\n"); for (i = i; i <= z->sedanjost; i++) { - fprintf(fd, "%u%s\n", i, strrchr(z->kos_format, '.')); + fprintf(fd2, "%u-%lu%s\n", i, casi[i], strrchr(z->kos_format, '.')); + } + free(casi); + casi = NULL; + for (i = (z->sedanjost)+1; 1 == 1; i++) { + cas = time(NULL); + if ((z->prenesenih_kosov_prihodnost)*(z->dolzina) >= z->prihodnost) { + i++; + RTV_NAPISI(INFO, "končal prihodnost: kosov: %u, sekund: %u.", + z->prenesenih_kosov_prihodnost, + (z->prenesenih_kosov_prihodnost)*(z->dolzina)); + break; + } + snprintf(fn, sizeof(fn), "%s/%u-%lu%s", + e, i, cas, strrchr(z->kos_format, '.')); + fd = fopen(fn, "w"); + snprintf(fn, sizeof(fn), z->kos_format, i); + returnstatus = http_get(fn, fd); + if (!RTV_HTTP_SUCCESS(returnstatus)) { + if (returnstatus != 404) { + RTV_NAPISI(NAPAKA, "strežnik odvrnil %u namesto 200/404.", + returnstatus); + returnstatus = 1; + fclose(fd2); + fclose(fd); + snprintf(fn, sizeof(fn), "%s/%u-%lu%s", + e, i, cas, strrchr(z->kos_format, '.')); + unlink(fn); + goto returncleanly; + break; + } + RTV_NAPISI(INFO, "kos ne obstaja, čakam %u sekund.", (z->dolzina)-1); + sleep(z->dolzina-1); + snprintf(fn, sizeof(fn), "%s/%u-%lu%s", + e, i, cas, strrchr(z->kos_format, '.')); + fclose(fd); + unlink(fn); + i--; /* ponovno poskusimo ta kos */ + continue; + } + fprintf(fd2, "%u-%lu%s\n", i, cas, strrchr(z->kos_format, '.')); + RTV_NAPISI(INFO, "prenesel kos %u iz prihodnosti", i); + z->prenesenih_kosov_prihodnost++; + fclose(fd); + returnstatus = 0; } + fclose(fd2); break; default: RTV_NAPISI(NAPAKA, "opcija (%c/%u) ne obstaja!", |