Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
blueset committed Aug 22, 2024
2 parents 3562c7f + 6d0c1ec commit 143276c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ RUN git clone --depth 1 https://github.com/neologd/mecab-ipadic-neologd.git /tmp

# Install Python 3 and dependencies
RUN apt-get install -y python3 python3-pip
RUN pip3 install yt-dlp --break-system-packages
RUN pip3 install yt-dlp https://github.com/coletdjnz/yt-dlp-youtube-oauth2/archive/refs/heads/master.zip --break-system-packages
RUN echo 'machine youtube login oauth2 password ""' > /etc/netrc.txt
RUN echo '--netrc --netrc-location /etc/netrc.txt' > /etc/yt-dlp.conf

RUN npm install -g concurrently

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const LyricsRow = forwardRef<LyricsRowRefs, LyricsRowProps>(function LyricsRow(
const lengths = measureTextWidths(target);
const length = lengths.at(-1);
const percentages = lengths.map((v) => (v / length) * 100);
const duration = end - start;
const duration = Math.max(end - start, 1);
const keyframes = tags.map((v) => ({
offset: Math.min(1, Math.max(v.timeTag / duration, 0)),
backgroundSize: `${percentages[v.index - 1] ?? 0}% 100%`,
Expand Down
7 changes: 4 additions & 3 deletions packages/jukebox/src/graphql/DownloadResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,13 @@ export class DownloadResolver {
publish: Publisher<PubSubSessionPayload<YouTubeDlProgressType>>
): Promise<string> {
const ytdlpWrap = new YTDlpWrap(YTDLP_PATH);
const format = url.includes("nicovideo") ? "best" : "bestaudio";
if (!filename) {
const info = await ytdlpWrap.getVideoInfo(url);
const info = await ytdlpWrap.getVideoInfo(["-f", format, url]);
filename = info.filename;
}
filename = swapExt(filename, "mp3");
const fullPath = Path.resolve(MUSIC_FILES_PATH, filename);
const format = url.includes("nicovideo") ? "best" : "bestaudio";
const params = [
url,
"--extract-audio",
Expand Down Expand Up @@ -444,7 +444,8 @@ export class DownloadResolver {
@Query((returns) => GraphQLJSONObject)
public async youtubeDlGetInfo(@Arg("url") url: string): Promise<object> {
const ytdlpWrap = new YTDlpWrap(YTDLP_PATH);
const info = await ytdlpWrap.getVideoInfo(url);
const format = url.includes("nicovideo") ? "best" : "bestaudio";
const info = await ytdlpWrap.getVideoInfo(["-f", format, url]);
// console.log("yt-dlp info", info);
if (Array.isArray(info))
throw new Error("Playlist download is not supported yet");
Expand Down

0 comments on commit 143276c

Please sign in to comment.