mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Merge d350f7604f
into 956b68c333
This commit is contained in:
commit
023504fd50
2 changed files with 25 additions and 3 deletions
|
@ -46,7 +46,7 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.timeStamp = parseInt(this.currentTime);
|
this.timeStamp = this.parseSecondsToTimeStamp(this.currentTime || 0);
|
||||||
this.withTimeCode = this.getPreferenceBoolean("shareWithTimeCode", true);
|
this.withTimeCode = this.getPreferenceBoolean("shareWithTimeCode", true);
|
||||||
this.pipedLink = this.getPreferenceBoolean("shareAsPipedLink", true);
|
this.pipedLink = this.getPreferenceBoolean("shareAsPipedLink", true);
|
||||||
},
|
},
|
||||||
|
@ -69,6 +69,27 @@ export default {
|
||||||
this.setPreference("shareWithTimeCode", this.withTimeCode, true);
|
this.setPreference("shareWithTimeCode", this.withTimeCode, true);
|
||||||
this.setPreference("shareAsPipedLink", this.pipedLink, true);
|
this.setPreference("shareAsPipedLink", this.pipedLink, true);
|
||||||
},
|
},
|
||||||
|
parseTimeStampToSeconds(timestamp) {
|
||||||
|
const timeArray = timestamp.split(":").reverse();
|
||||||
|
let seconds = 0;
|
||||||
|
const durations = [1, 60, 60 * 60, 60 * 60 * 24];
|
||||||
|
for (let i = 0; i < timeArray.length; i++) {
|
||||||
|
seconds += timeArray[i] * durations[i];
|
||||||
|
}
|
||||||
|
return seconds;
|
||||||
|
},
|
||||||
|
parseSecondsToTimeStamp(seconds) {
|
||||||
|
const timeArray = [];
|
||||||
|
const durations = [1, 60, 60 * 60, 60 * 60 * 24].reverse();
|
||||||
|
for (let i in durations) {
|
||||||
|
const currentValue = Math.floor(seconds / durations[i]);
|
||||||
|
if (currentValue > 0) {
|
||||||
|
timeArray.push(currentValue.toString().padStart(2, "0"));
|
||||||
|
seconds -= currentValue * durations[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return timeArray.join(":");
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
generatedLink() {
|
generatedLink() {
|
||||||
|
@ -76,7 +97,8 @@ export default {
|
||||||
? window.location.origin + "/watch?v=" + this.videoId
|
? window.location.origin + "/watch?v=" + this.videoId
|
||||||
: "https://youtu.be/" + this.videoId;
|
: "https://youtu.be/" + this.videoId;
|
||||||
var url = new URL(baseUrl);
|
var url = new URL(baseUrl);
|
||||||
if (this.withTimeCode && this.timeStamp > 0) url.searchParams.append("t", this.timeStamp);
|
if (this.withTimeCode && this.timeStamp)
|
||||||
|
url.searchParams.append("t", this.parseTimeStampToSeconds(this.timeStamp));
|
||||||
return url.href;
|
return url.href;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
"piped_link": "Piped link",
|
"piped_link": "Piped link",
|
||||||
"follow_link": "Follow link",
|
"follow_link": "Follow link",
|
||||||
"copy_link": "Copy link",
|
"copy_link": "Copy link",
|
||||||
"time_code": "Time code (in seconds)",
|
"time_code": "Time code (in seconds or HH:MM:SS)",
|
||||||
"show_chapters": "Chapters",
|
"show_chapters": "Chapters",
|
||||||
"store_search_history": "Store Search history",
|
"store_search_history": "Store Search history",
|
||||||
"hide_watched": "Hide watched videos in the feed",
|
"hide_watched": "Hide watched videos in the feed",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue