Skip to content

Commit

Permalink
Allow downloading HEVC videos
Browse files Browse the repository at this point in the history
  • Loading branch information
qsniyg committed Oct 23, 2024
1 parent b21fe57 commit ffeda9d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 14 deletions.
57 changes: 48 additions & 9 deletions src/userscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124702,6 +124702,9 @@ var $$IMU_EXPORT$$;
}

if (media_info.codec === "hevc") {
if (!processing.browser_viewable)
return true;

// TODO: check for HEVC support
return false;
}
Expand Down Expand Up @@ -126145,7 +126148,7 @@ var $$IMU_EXPORT$$;
waitingel.style.top = (y - (waitingsize / 2)) + "px";
}

var start_waiting = function(el, cursor) {
var start_waiting = function(el, cursor?:string) {
if (!cursor)
cursor = "wait";

Expand Down Expand Up @@ -132727,6 +132730,8 @@ var $$IMU_EXPORT$$;
use_head = true;
}

let browser_viewable = use_head; // incidentally the same

var old_source = source;

var incomplete_image = false;
Expand All @@ -132752,7 +132757,8 @@ var $$IMU_EXPORT$$;
use_head: use_head,
incomplete_image: incomplete_image,
incomplete_video: incomplete_video,
use_last_pos: use_last_pos
use_last_pos: use_last_pos,
browser_viewable: browser_viewable
}, function(source_imu, source, processing, data) {
if (!source_imu && !source && !processing && !data) {
delay_handle_triggering = false;
Expand Down Expand Up @@ -132824,6 +132830,20 @@ var $$IMU_EXPORT$$;
});
}

type Processing = {
running: boolean,
incomplete_image?: boolean,
incomplete_video?: boolean,
progress_cb?: () => void, // todo
head?: boolean,
browser_viewable?: boolean // codecs, filetypes
set_cache?: boolean,
use_cache?: boolean,
deny_nondirect_delivery?: boolean,
deny_video?: boolean,
deny_audio?: boolean,
source?: any
}
type GFFS_HeadData = {
resp: HTMLElement,
obj: string
Expand All @@ -132835,11 +132855,24 @@ var $$IMU_EXPORT$$;
respdata: Object
}
type GFFS_Data = GFFS_HeadData | GFFS_GetData
function get_final_from_source(source, options, cb) {
type GFFS_Options = {
use_last_pos?: boolean,
incomplete_image?: boolean,
incomplete_video?: boolean,
progress_cb?: () => void, // FIXME
use_head?: boolean,
browser_viewable?: boolean // codecs, filetypes
deny_cache?: boolean,
deny_nondirect_delivery?: boolean,
null_if_no_change?: boolean,
multi?: boolean,
automatic?: boolean
}
function get_final_from_source(source, options:GFFS_Options, cb) {
// FIXME: "multi" is used purely for replace_images,
// so it's used as a check for many options that have nothing to do with multi

var processing = {running: true};
var processing:Processing = {running: true};

if (!options.multi) {
stop_processing();
Expand Down Expand Up @@ -132908,7 +132941,7 @@ var $$IMU_EXPORT$$;
// brl returns [] if they're bad, but the bad sources are added right back here
if (!settings.mouseover_exclude_sameimage) {
if (source.src && obj_indexOf(newobj, source.src) < 0)
newobj.push(fillobj(source.src)[0]);
newobj.push(fillobj(source.src)[0]); // FIXME: fillobj needs a second argument
} else if (source.src) {
var index;

Expand All @@ -132930,6 +132963,8 @@ var $$IMU_EXPORT$$;
processing.incomplete_video = options.incomplete_video;
processing.progress_cb = options.progress_cb;

processing.browser_viewable = options.browser_viewable;

if (options.use_head) {
processing.head = true;
}
Expand Down Expand Up @@ -133819,7 +133854,8 @@ var $$IMU_EXPORT$$;
incomplete_video: incomplete,
null_if_no_change: null_if_no_change,
use_last_pos: false,
progress_cb: progress_cb
progress_cb: progress_cb,
browser_viewable: options.browser_viewable
}, function (source_imu, source, processing, data) {
domain_processed_cb();

Expand Down Expand Up @@ -133989,7 +134025,8 @@ var $$IMU_EXPORT$$;
links_newtab: settings.replaceimgs_links_newtab,
size_constraints: get_single_setting("replaceimgs_size_constraints"),
replace_css: settings.replaceimgs_css,
use_progressbar: true
use_progressbar: true,
browser_viewable: true
};

var plainlinks_option = get_single_setting("replaceimgs_plainlinks");
Expand Down Expand Up @@ -134619,10 +134656,11 @@ var $$IMU_EXPORT$$;
replace_images_full({
images: els,
all_els_ok: true,
browser_viewable: false,
replace_image_func: function(options, our_source, cb, domain_processed_cb, progress_cb) {
//console_log(our_source);

var gffs_options = {
var gffs_options:GFFS_Options = {
automatic: true,
multi: true,
use_head: false,
Expand All @@ -134632,7 +134670,8 @@ var $$IMU_EXPORT$$;
deny_cache: true,
null_if_no_change: !settings.gallery_download_unchanged,
use_last_pos: false,
progress_cb: progress_cb
progress_cb: progress_cb,
browser_viewable: false
};

if (download_method === "jdownloader") {
Expand Down
19 changes: 14 additions & 5 deletions userscript.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -111446,6 +111446,8 @@ var $$IMU_EXPORT$$;
return false;
}
if (media_info.codec === "hevc") {
if (!processing.browser_viewable)
return true;
// TODO: check for HEVC support
return false;
}
Expand Down Expand Up @@ -117991,6 +117993,7 @@ var $$IMU_EXPORT$$;
if (openb === "newtab" || openb === "newtab_bg" || openb === "download" || openb === "copylink") {
use_head = true;
}
var browser_viewable = use_head; // incidentally the same
var old_source = source;
var incomplete_image = false;
var incomplete_video = false;
Expand All @@ -118011,7 +118014,8 @@ var $$IMU_EXPORT$$;
use_head: use_head,
incomplete_image: incomplete_image,
incomplete_video: incomplete_video,
use_last_pos: use_last_pos
use_last_pos: use_last_pos,
browser_viewable: browser_viewable
}, function(source_imu, source, processing, data) {
if (!source_imu && !source && !processing && !data) {
delay_handle_triggering = false;
Expand Down Expand Up @@ -118131,7 +118135,7 @@ var $$IMU_EXPORT$$;
// brl returns [] if they're bad, but the bad sources are added right back here
if (!settings.mouseover_exclude_sameimage) {
if (source.src && obj_indexOf(newobj, source.src) < 0)
newobj.push(fillobj(source.src)[0]);
newobj.push(fillobj(source.src)[0]); // FIXME: fillobj needs a second argument
} else if (source.src) {
var index;
while ((index = obj_indexOf(newobj, source.src)) >= 0) {
Expand All @@ -118149,6 +118153,7 @@ var $$IMU_EXPORT$$;
processing.incomplete_image = options.incomplete_image;
processing.incomplete_video = options.incomplete_video;
processing.progress_cb = options.progress_cb;
processing.browser_viewable = options.browser_viewable;
if (options.use_head) {
processing.head = true;
}
Expand Down Expand Up @@ -118879,7 +118884,8 @@ var $$IMU_EXPORT$$;
incomplete_video: incomplete,
null_if_no_change: null_if_no_change,
use_last_pos: false,
progress_cb: progress_cb
progress_cb: progress_cb,
browser_viewable: options.browser_viewable
}, function(source_imu, source, processing, data) {
domain_processed_cb();
if (!data) {
Expand Down Expand Up @@ -119014,7 +119020,8 @@ var $$IMU_EXPORT$$;
links_newtab: settings.replaceimgs_links_newtab,
size_constraints: get_single_setting("replaceimgs_size_constraints"),
replace_css: settings.replaceimgs_css,
use_progressbar: true
use_progressbar: true,
browser_viewable: true
};
var plainlinks_option = get_single_setting("replaceimgs_plainlinks");
if (plainlinks_option !== "none") {
Expand Down Expand Up @@ -119526,6 +119533,7 @@ var $$IMU_EXPORT$$;
replace_images_full({
images: els,
all_els_ok: true,
browser_viewable: false,
replace_image_func: function(options, our_source, cb, domain_processed_cb, progress_cb) {
//console_log(our_source);
var gffs_options = {
Expand All @@ -119538,7 +119546,8 @@ var $$IMU_EXPORT$$;
deny_cache: true,
null_if_no_change: !settings.gallery_download_unchanged,
use_last_pos: false,
progress_cb: progress_cb
progress_cb: progress_cb,
browser_viewable: false
};
if (download_method === "jdownloader") {
gffs_options.use_head = true;
Expand Down

0 comments on commit ffeda9d

Please sign in to comment.