Use the on-disk filename in the content-disposition header when downloading recordings in the webui. The old behaviour was to just take the episode title, and would generate a ".bin" extension for passthrough (TS) recordings.
This commit is contained in:
parent
99ed831f37
commit
6e4a22a52d
1 changed files with 16 additions and 16 deletions
|
@ -1103,9 +1103,10 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
|
|||
{
|
||||
int fd, i;
|
||||
struct stat st;
|
||||
const char *content = NULL, *postfix, *range;
|
||||
const char *content = NULL, *range;
|
||||
dvr_entry_t *de;
|
||||
char *fname;
|
||||
char *basename;
|
||||
char range_buf[255];
|
||||
char disposition[256];
|
||||
off_t content_len, chunk;
|
||||
|
@ -1129,10 +1130,23 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
|
|||
|
||||
fname = strdup(de->de_filename);
|
||||
content = muxer_container_type2mime(de->de_mc, 1);
|
||||
postfix = muxer_container_suffix(de->de_mc, 1);
|
||||
|
||||
pthread_mutex_unlock(&global_lock);
|
||||
|
||||
basename = strrchr(fname, '/');
|
||||
if (basename) {
|
||||
basename++; /* Skip '/' */
|
||||
snprintf(disposition, sizeof(disposition), "attachment; filename=\"%s\"", basename);
|
||||
// Ensure there are no " characters in the filename.
|
||||
i = strlen(disposition)-2;
|
||||
while (i > 21) {
|
||||
if (disposition[i] == '"') { disposition[i] = '_'; }
|
||||
i--;
|
||||
}
|
||||
} else {
|
||||
disposition[0] = 0;
|
||||
}
|
||||
|
||||
fd = tvh_open(fname, O_RDONLY, 0);
|
||||
free(fname);
|
||||
if(fd < 0)
|
||||
|
@ -1173,20 +1187,6 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
|
|||
if(file_start > 0)
|
||||
lseek(fd, file_start, SEEK_SET);
|
||||
|
||||
if(de->de_title != NULL) {
|
||||
snprintf(disposition, sizeof(disposition),
|
||||
"attachment; filename=%s.%s", lang_str_get(de->de_title, NULL), postfix);
|
||||
i = 20;
|
||||
while(disposition[i]) {
|
||||
if(disposition[i] == ' ')
|
||||
disposition[i] = '_';
|
||||
i++;
|
||||
}
|
||||
|
||||
} else {
|
||||
disposition[0] = 0;
|
||||
}
|
||||
|
||||
http_send_header(hc, range ? HTTP_STATUS_PARTIAL_CONTENT : HTTP_STATUS_OK,
|
||||
content, content_len, NULL, NULL, 10,
|
||||
range ? range_buf : NULL,
|
||||
|
|
Loading…
Add table
Reference in a new issue