Skip to content

Commit

Permalink
Update interface, remove update ytdl menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
lhc70000 committed Nov 26, 2024
1 parent 8b15be1 commit 9470790
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 147 deletions.
4 changes: 2 additions & 2 deletions Info.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "Online Media",
"identifier": "io.iina.ytdl",
"version": "1.0.0",
"version": "0.9.1",
"ghRepo": "iina/plugin-online-media",
"ghVersion": 2,
"ghVersion": 3,
"description": "Official plugin for playing online media via yt-dlp / youtube-dl. The built-in youtube-dl support will be disabled when this plugin is enabled.",
"author": {
"name": "IINA Developers",
Expand Down
5 changes: 3 additions & 2 deletions downloads.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Status</title>
<title>Status and Downloads</title>
<style>
body {
color-scheme: light dark;
font-size: 13px;
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
user-select: none;
Expand Down Expand Up @@ -176,7 +177,7 @@ <h4>Status</h4>
<div class="info-container">
<div class="binary-msg" id="binary-desc">Checking for yt-dlp binary...</div>
<div class="binary-msg" id="binary-version"></div>
<button id="download-binary">Download or update yt-dlp</button>
<button id="download-binary">Download latest yt-dlp</button>
<div class="download-container">
<div id="downloading">
<div class="message">Downloading yt-dlp…</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iina-plugin-ytdl",
"version": "0.9.0",
"version": "0.9.1",
"description": "",
"main": "src/index.js",
"scripts": {
Expand Down
231 changes: 104 additions & 127 deletions pref.html
Original file line number Diff line number Diff line change
@@ -1,132 +1,109 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
* {
box-sizing: border-box;
}
html {
margin: 0;
padding: 0;
}
body {
padding: 16px;
margin: 0;
font-size: 13px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
p {
margin: 0;
}
small,
.small {
font-size: 11px;
}
.secondary {
color: rgba(0, 0, 0, 0.5);
}
.pref-section {
margin-bottom: 12px;
}
.pref-help {
margin-top: 2px;
}
</style>
</head>
<body>
<div class="pref-section">
Use custom youtube-dl/yt-dlp:
<div style="margin-top: 2px">
<input
type="text"
data-pref-key="ytdl_path"
style="width: 100%; margin-top: 2px"
/>
</div>

<head>
<meta charset="UTF-8" />
<title>Document</title>
<style>
* {
box-sizing: border-box;
}

html {
margin: 0;
padding: 0;
}

body {
padding: 16px;
margin: 0;
font-size: 13px;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

p {
margin: 0;
}

small,
.small {
font-size: 11px;
}

.secondary {
color: rgba(0, 0, 0, 0.5);
}

.pref-section {
margin-bottom: 12px;
}

.pref-help {
margin-top: 2px;
}
</style>
</head>

<body>
<div class="pref-section">
Use custom youtube-dl/yt-dlp:
<p class="small secondary pref-help">
Enter the path to the youtube-dl or yt-dlp binary.
If you are using Homebrew, the path is usually <code>/opt/homebrew/bin/yt-dlp</code>.
</p>
<div style="margin-top: 2px">
<input type="text" data-pref-key="ytdl_path" style="width: 100%; margin-top: 2px" />
</div>
<div class="pref-section">
Default video and audio quality:
<div style="margin-top: 4px; line-height: 24px">
<div>
<label
><input
type="radio"
name="video_quality"
value="best"
data-pref-key
/>
Best video and audio</label
>
</div>
<div>
<label
><input
type="radio"
name="video_quality"
value="use_max"
data-pref-key
/>
Video not larger than:</label
>
<input
type="number"
data-pref-key="max_video_height"
style="width: 4em"
/>
p
</div>
<div>
<label
><input
type="radio"
name="video_quality"
value="custom"
data-pref-key
/>
Custom youtube-dl format:</label
>
<input type="text" data-pref-key="custom_ytdl_format" />
</div>
</div>
<div class="pref-section">
Default video and audio quality:
<div style="margin-top: 4px; line-height: 24px">
<div>
<label><input type="radio" name="video_quality" value="best" data-pref-key />
Best video and audio</label>
</div>
<div>
<label><input type="radio" name="video_quality" value="use_max" data-pref-key />
Video not larger than:</label>
<input type="number" data-pref-key="max_video_height" style="width: 4em" />
p
</div>
<div>
<label><input type="radio" name="video_quality" value="custom" data-pref-key />
Custom youtube-dl format:</label>
<input type="text" data-pref-key="custom_ytdl_format" />
</div>
</div>
<div class="pref-section">
<label>
Excluded URLs:
<div style="margin-top: 2px">
<input
type="text"
data-pref-key="excluded_urls"
style="width: 100%; margin-top: 2px"
/>
</div>
</label>
</div>
<div class="pref-section">
<label>
<input
type="checkbox"
data-type="bool"
data-pref-key="try_ytdl_first"
/>
Try youtube-dl first
</label>
<p class="small secondary pref-help">
Try parsing the URL with youtube-dl first, instead of the default where
it's only after mpv failed to open it.
</p>
</div>
<div class="pref-section">
<label>
<input type="checkbox" data-type="bool" data-pref-key="use_manifest" />
Use manifest URL
</label>
<p class="small secondary pref-help">
Use the master manifest URL for formats like HLS and DASH, if available,
allowing for video/audio selection in runtime.
</p>
</div>
</body>
</html>
</div>
<div class="pref-section">
<label>
Excluded URLs:
<div style="margin-top: 2px">
<input type="text" data-pref-key="excluded_urls" style="width: 100%; margin-top: 2px" />
</div>
</label>
</div>
<div class="pref-section">
<label>
<input type="checkbox" data-type="bool" data-pref-key="try_ytdl_first" />
Try youtube-dl first
</label>
<p class="small secondary pref-help">
Try parsing the URL with youtube-dl first, instead of the default where
it's only after mpv failed to open it.
</p>
</div>
<div class="pref-section">
<label>
<input type="checkbox" data-type="bool" data-pref-key="use_manifest" />
Use manifest URL
</label>
<p class="small secondary pref-help">
Use the master manifest URL for formats like HLS and DASH, if available,
allowing for video/audio selection in runtime.
</p>
</div>
</body>

</html>
7 changes: 5 additions & 2 deletions src/downloads-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ function b64_to_utf8(str) {
}

function updateBinaryInfo() {
document.getElementById("binary-desc").textContent =
"Checking for yt-dlp binary...";
iina.postMessage("getBinaryInfo");
iina.onMessage("binaryInfo", ({ path, version, errorMessage }) => {
let description,
Expand All @@ -85,15 +87,16 @@ function updateBinaryInfo() {
} else {
binaryLocation = path;
description = `It seems that you are using a custom yt-dlp binary. You may need to update it manually.`;
document.getElementById("download-binary").style.display = "none";
}
if (errorMessage) {
document.getElementById("binary-version").textContent = errorMessage;
} else {
let message = "Version: " + version;
if (binaryLocation) {
message += ", binary location: " + binaryLocation
message += `<br>binary location: ${binaryLocation}`;
}
document.getElementById("binary-version").textContent = message;
document.getElementById("binary-version").innerHTML = message;
}
document.getElementById("binary-desc").textContent = description;
});
Expand Down
29 changes: 16 additions & 13 deletions src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ let { console, core, global, menu, standaloneWindow, utils } = iina;
// Menu

menu.addItem(
menu.item("Update yt-dlp...", async () => {
showDownloadYTDLPWindow();
}),
);

menu.addItem(
menu.item("Show Status and Downloads...", async () => {
menu.item("Manage yt-dlp and Downloads...", async () => {
showDownloadsWindow();
}),
);
Expand Down Expand Up @@ -69,17 +63,26 @@ function showDownloadsWindow() {
standaloneWindow.onMessage("getBinaryInfo", async () => {
const path = findBinary();
console.log("Binary path: " + path);
const res = await utils.exec(path, ["--version"])
const res = await utils.exec(path, ["--version"]);
if (res.status === 0) {
const version = res.stdout
const version = res.stdout;
console.log("Version: " + version);
standaloneWindow.postMessage("binaryInfo", { path, version, errorMessage: "" });
standaloneWindow.postMessage("binaryInfo", {
path,
version,
errorMessage: "",
});
} else {
const errorMessage = "Error when executing the binary: " + (res.stderr ? res.stderr : "No error message");
const errorMessage =
"Error when executing the binary: " +
(res.stderr ? res.stderr : "No error message");
console.log(errorMessage);
standaloneWindow.postMessage("binaryInfo", { path, version: "", errorMessage });
standaloneWindow.postMessage("binaryInfo", {
path,
version: "",
errorMessage,
});
}

});

standaloneWindow.onMessage("updateBinary", () => {
Expand Down

0 comments on commit 9470790

Please sign in to comment.