mirror of
https://github.com/neosubhamoy/pytubepp-helper.git
synced 2026-02-04 11:22:22 +05:30
(refactor): updated some (windows) naming conventions
This commit is contained in:
@@ -7,7 +7,7 @@ import { ThemeProvider } from "@/components/theme-provider";
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
|
||||||
import { InstalledPrograms, WebSocketMessage, } from "./types";
|
import { InstalledPrograms, WebSocketMessage, } from "./types";
|
||||||
import { compareVersions, extract_version, is_installed, sendStreamInfo } from "./lib/utils";
|
import { compareVersions, extractVersion, isInstalled, sendStreamInfo } from "./lib/utils";
|
||||||
import { CircleCheck, TriangleAlert, CircleAlert } from 'lucide-react';
|
import { CircleCheck, TriangleAlert, CircleAlert } from 'lucide-react';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
@@ -71,56 +71,56 @@ function App() {
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function check_all_programs() {
|
function checkAllPrograms() {
|
||||||
is_installed('winget', '--version').then((result) => {
|
isInstalled('winget', '--version').then((result) => {
|
||||||
setInstalledPrograms((prevState) => ({
|
setInstalledPrograms((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
winget: {
|
winget: {
|
||||||
installed: result.installed,
|
installed: result.installed,
|
||||||
version: result.output ? extract_version(result.output) : null,
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
is_installed('python', '--version').then((result) => {
|
isInstalled('python', '--version').then((result) => {
|
||||||
setInstalledPrograms((prevState) => ({
|
setInstalledPrograms((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
python: {
|
python: {
|
||||||
installed: result.installed,
|
installed: result.installed,
|
||||||
version: result.output ? extract_version(result.output) : null,
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
is_installed('pip', '--version').then((result) => {
|
isInstalled('pip', '--version').then((result) => {
|
||||||
setInstalledPrograms((prevState) => ({
|
setInstalledPrograms((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
pip: {
|
pip: {
|
||||||
installed: result.installed,
|
installed: result.installed,
|
||||||
version: result.output ? extract_version(result.output) : null,
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
is_installed('ffmpeg', '-version').then((result) => {
|
isInstalled('ffmpeg', '-version').then((result) => {
|
||||||
setInstalledPrograms((prevState) => ({
|
setInstalledPrograms((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
ffmpeg: {
|
ffmpeg: {
|
||||||
installed: result.installed,
|
installed: result.installed,
|
||||||
version: result.output ? extract_version(result.output) : null,
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
is_installed('pytubepp', '--version').then((result) => {
|
isInstalled('pytubepp', '--version').then((result) => {
|
||||||
setInstalledPrograms((prevState) => ({
|
setInstalledPrograms((prevState) => ({
|
||||||
...prevState,
|
...prevState,
|
||||||
pytubepp: {
|
pytubepp: {
|
||||||
installed: result.installed,
|
installed: result.installed,
|
||||||
version: result.output ? extract_version(result.output) : null,
|
version: result.output ? extractVersion(result.output) : null,
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
check_all_programs();
|
checkAllPrograms();
|
||||||
}
|
}
|
||||||
, []);
|
, []);
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ function App() {
|
|||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="topbar flex justify-between items-center mt-5">
|
<div className="topbar flex justify-between items-center mt-5">
|
||||||
<h1 className="text-xl font-bold">PytubePP Helper</h1>
|
<h1 className="text-xl font-bold">PytubePP Helper</h1>
|
||||||
<Button size="sm" onClick={check_all_programs}>Refresh</Button>
|
<Button size="sm" onClick={checkAllPrograms}>Refresh</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="programstats mt-5">
|
<div className="programstats mt-5">
|
||||||
<div className="programitem flex items-center justify-between">
|
<div className="programitem flex items-center justify-between">
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export function cn(...inputs: ClassValue[]) {
|
|||||||
return twMerge(clsx(inputs))
|
return twMerge(clsx(inputs))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function is_installed(program: string, arg: string): Promise<{ installed: boolean, output: string | null }> {
|
export async function isInstalled(program: string, arg: string): Promise<{ installed: boolean, output: string | null }> {
|
||||||
try{
|
try{
|
||||||
const output = await new Command('is-' + program + '-installed', [arg]).execute();
|
const output = await new Command('is-' + program + '-installed', [arg]).execute();
|
||||||
if (output.code === 0) {
|
if (output.code === 0) {
|
||||||
@@ -21,7 +21,7 @@ export async function is_installed(program: string, arg: string): Promise<{ inst
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extract_version(output: string): string | null {
|
export function extractVersion(output: string): string | null {
|
||||||
const versionPatterns = [
|
const versionPatterns = [
|
||||||
/ffmpeg version (\d+\.\d+)/, // Pattern for ffmpeg
|
/ffmpeg version (\d+\.\d+)/, // Pattern for ffmpeg
|
||||||
/Python (\d+\.\d+\.\d+)/, // Pattern for Python
|
/Python (\d+\.\d+\.\d+)/, // Pattern for Python
|
||||||
|
|||||||
Reference in New Issue
Block a user