Skip to content

Commit

Permalink
Move timestamps_to_keep() to cut.d
Browse files Browse the repository at this point in the history
  • Loading branch information
faissaloo committed Oct 11, 2020
1 parent 3990eea commit c06c12f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
25 changes: 25 additions & 0 deletions src/sponskrub/methods/cut.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,31 @@ import std.typecons;
import sponsorblock;
import ffwrap;

ClipTime[] timestamps_to_keep(ClipTime[] sponsor_times, string video_length) {
ClipTime[] clip_times;
sponsor_times.sort!((a, b) => a.start.to!float < b.start.to!float);

//If the sponsorship is directly at the beginning don't add both content and the sponsor
if (sponsor_times[0].start != "0.000000") {
clip_times ~= ClipTime("0", sponsor_times[0].start, "content");
}


for (auto i = 0; i < sponsor_times.length; i++) {
auto clip_start = "";
auto clip_end = "";
clip_start = sponsor_times[i].end;
if (i+1 < sponsor_times.length) {
clip_end = sponsor_times[i+1].start;
} else {
clip_end = video_length;
}
clip_times ~= ClipTime(clip_start, clip_end, "content");
}

return clip_times;
}

string cut_and_cat_clips_filter(ClipTime[] timestamps, FileCategory category) {
timestamps.sort!((a, b) => a.start.to!float < b.start.to!float);

Expand Down
26 changes: 0 additions & 26 deletions src/sponskrub/sponskrub.d
Original file line number Diff line number Diff line change
Expand Up @@ -185,32 +185,6 @@ Options:
}
}

ClipTime[] timestamps_to_keep(ClipTime[] sponsor_times, string video_length) {
ClipTime[] clip_times;

sponsor_times.sort!((a, b) => a.start.to!float < b.start.to!float);

//If the sponsorship is directly at the beginning don't add both content and the sponsor
if (sponsor_times[0].start != "0.000000") {
clip_times ~= ClipTime("0", sponsor_times[0].start, "content");
}


for (auto i = 0; i < sponsor_times.length; i++) {
auto clip_start = "";
auto clip_end = "";
clip_start = sponsor_times[i].end;
if (i+1 < sponsor_times.length) {
clip_end = sponsor_times[i+1].start;
} else {
clip_end = video_length;
}
clip_times ~= ClipTime(clip_start, clip_end, "content");
}

return clip_times;
}

Categories[] categories_from_arguments(Args arguments) {
Categories[] categories = [];
if ("exclude-sponsors" !in arguments.flag_arguments) {
Expand Down

0 comments on commit c06c12f

Please sign in to comment.