Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraWebdev committed Jan 11, 2025
1 parent 05a4253 commit 46b9dc0
Show file tree
Hide file tree
Showing 3,051 changed files with 1,674 additions and 411,363 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
File renamed without changes.
4 changes: 3 additions & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@
FROM node:22

# Set working directory
WORKDIR /usr/src/app

# Copy package.json and package-lock.json (for both backend and frontend dependencies)
COPY package.json package-lock.json ./

# Install root-level dependencies (if any)
RUN npm install
WORKDIR /usr/src/app/server

# Copy and install backend dependencies
COPY ./server/package.json ./server/package-lock.json ./server/
RUN npm install --prefix ./server
COPY ./server/package.json ./server/package-lock.json ./
RUN npm install
COPY ./server ./

# Build and install Vue frontend
WORKDIR /usr/src/app/ui
Expand All @@ -30,7 +25,7 @@ RUN cp -r ui/dist/* server/public
WORKDIR /usr/src/app

# Expose the backend server port
EXPOSE 3000
EXPOSE 8080

# Set the entry point to start the backend server
CMD ["node", "server/app.js"]
22 changes: 0 additions & 22 deletions README.Docker.md

This file was deleted.

28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# KHInsider Downloader
## WebUI

![](./docs/screenshot.png)

A simple docker container & web UI to download media from downloads.khinsider.com

## Variables
| Variable | Description | Required | Default |
|-----------------|----------------------------------------------------------|----------|--------------|
| OUTPUT_DIR | The output directory for downloads. Can be a volume path | `no` | Project root |
| REQUEST_TIMEOUT | Time until requests timeout | `no` | 30 seconds |

## Docker Compose
```yaml
services:
server:
build:
context: .
environment:
NODE_ENV: production
OUTPUT_DIR: "/output"
REQUEST_TIMEOUT: 30000
volumes:
- "./path/for/your/downloads:/output"
ports:
- "8080:8080"
```
4 changes: 4 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ services:
context: .
environment:
NODE_ENV: production
OUTPUT_DIR: "/output"
REQUEST_TIMEOUT: 30000
volumes:
- "./test:/output"
ports:
- "8080:8080"
Binary file added docs/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 0 additions & 11 deletions package.json

This file was deleted.

24 changes: 24 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules/
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
16 changes: 13 additions & 3 deletions server/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
const express = require('express');
const path = require("path");
const cors = require('cors');
const listEndpoints = require('express-list-endpoints');

const OUTPUT_DIR = process.env.OUTPUT_DIR || path.join(process.cwd(), '..');
const REQUEST_TIMEOUT = process.env.REQUEST_TIMEOUT || 30000;

console.log("[KHID WebUI] Starting");
console.info(`[KHID WebUI] OUTPUT_DIR: ${OUTPUT_DIR}`);
console.info(`[KHID WebUI] REQUEST_TIMEOUT: ${REQUEST_TIMEOUT}`);

const app = express();
app.use(express.json());
app.use(express.json({

}));
app.use(cors());

// Server Routes
app.use('/api', require('./routes'));
Expand All @@ -19,5 +30,4 @@ app.get('*', (req, res) => {
});

// Start server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));
app.listen(8080, () => console.log(`[KHID WebUI] Server started on port 8080`));
36 changes: 20 additions & 16 deletions server/modules/getSoundtrackMeta.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const axios = require('axios');
const cheerio = require('cheerio');

const REQUEST_TIMEOUT = process.env.REQUEST_TIMEOUT || 30000;

async function getSoundtrackMeta(urlOrSlug) {
console.log(`[DownloadQueue] GetSoundtrackMeta: ${urlOrSlug}`);
console.log(`[GetSoundtrackMeta] ${urlOrSlug}`);

// Build the album URL
const albumUrl = urlOrSlug.startsWith("https://downloads.khinsider.com")
Expand All @@ -11,28 +13,30 @@ async function getSoundtrackMeta(urlOrSlug) {

try {
// Fetch the album webpage
const response = await axios.get(albumUrl);
const response = await axios.get(albumUrl, {
timeout: REQUEST_TIMEOUT,
});
const html = response.data;
const $ = cheerio.load(html);

// Check if the soundtrack page exists
const pageTitle = $("head > title").text();
if (pageTitle === "Error") {
console.log("[DownloadQueue] Soundtrack does not exist!");
console.log("[GetSoundtrackMeta] Soundtrack does not exist!");
return null;
}

// Retrieve the album title
const albumTitle = $("#pageContent > h2").first().text().trim();
console.log(`[DownloadQueue] Soundtrack Name: ${albumTitle}`);
console.log(`[GetSoundtrackMeta] Soundtrack Name: ${albumTitle}`);

// Initialize the soundtrack object
const soundtrack = {
Url: albumUrl,
Title: albumTitle,
Slug: albumUrl.replace("https://downloads.khinsider.com/game-soundtracks/album/", ""),
Formats: [],
Songs: []
url: albumUrl,
title: albumTitle,
slug: albumUrl.replace("https://downloads.khinsider.com/game-soundtracks/album/", ""),
formats: [],
songs: []
};

// File Formats
Expand All @@ -48,10 +52,10 @@ async function getSoundtrackMeta(urlOrSlug) {

// Exclude non-format headers
if (!["", " ", "CD", "#", "Song Name"].includes(headerText)) {
soundtrack.Formats.push(headerText.toLowerCase());
soundtrack.formats.push(headerText.toLowerCase());
}
});
console.log(`[DownloadQueue] Formats: ${soundtrack.Formats.join(", ")}`);
console.log(`[GetSoundtrackMeta] Formats: ${soundtrack.formats.join(", ")}`);

// Determine the title column index
let titleColumn = 2;
Expand All @@ -66,17 +70,17 @@ async function getSoundtrackMeta(urlOrSlug) {
if (songAnchor.length) {
const href = songAnchor.attr("href");
const song = {
Title: songAnchor.text().trim(),
Url: `https://downloads.khinsider.com${href}`
title: songAnchor.text().trim(),
url: `https://downloads.khinsider.com${href}`
};
soundtrack.Songs.push(song);
soundtrack.songs.push(song);
}
});
console.log(`[DownloadQueue] Songs: ${soundtrack.Songs.length}`);
console.log(`[GetSoundtrackMeta] Songs: ${soundtrack.songs.length}`);

return soundtrack;
} catch (error) {
console.error(`[DownloadQueue] Error: ${error.message}`);
console.error(`[GetSoundtrackMeta] Error: ${error.message}`);
return null;
}
}
Expand Down
Loading

0 comments on commit 46b9dc0

Please sign in to comment.