Giter Club home page Giter Club logo

youtube-cue's Introduction

youtube-cue npm Libraries.io dependency status for latest release NPM Snyk Vulnerabilities for npm package Total Dependencies

Generate CUE sheet from timestamps in youtube video description.

What is this for?

  1. If you have DJ-mix or album on YouTube that you'd like to generate a CUE sheet for.
  2. The video has timestamps in the video description.
  3. The video is publicly available on Youtube.

youtube-cue will read the video description, get the timestamps and generate a CUE sheet accordingly. It will also work if track durations are used instead of timestamps.

Anti-features

  1. It does not download tracks from YouTube
  2. It does not split your tracks
  3. It does not tag your tracks.

For all of the above, there are better tools available, such as youtube-dl, m4acut, mp3splt, cuetools, beets and many more. youtube-cue tries to do one thing well.

Installation

npm install -g youtube-cue

Upgrade

npm update -g youtube-cue

Usage

You need to pass 2 parameters, a Youtube URL and a output CUE filename. YouTube short URLs (youtu.be) are accepted. You can additionally pass a audio-file argument which is used for the FILE specified in the CUE file.

youtube-cue [--audio-file audio.m4a] <youtube_url> [output_file]

Options
  --help, Show help
  --audio-file, Input Audio File (optional) that is written to the CUE sheet

The default audio file is set to %VIDEOTITLE.m4a
The default output file is set to %VIDEOTITLE.cue

where $VIDEOTITLE is the title of the YouTube video.

Generally the parser detects whether numbers are positional timestamps or track durations.
To enforce a desired interpretation you can use these flags:

--timestamps Parse as positional timestamps (relative to the start of the playlist)
--durations Parse as track durations

The above 2 are only needed to force behaviour in
very specific edge cases, they should not be required for most files.

Examples
  $ youtube-cue --audio-file audio.m4a "https://www.youtube.com/watch?v=WzpmVxvoBoc" "The Groovy Nobody - Solarium.cue"
    "The Groovy Nobody - Solarium.cue" saved

Personal Usage

I have this in my .bashrc to download, split, tag, and import albums using beet:

function ytdl.album() {
  cd $(mktemp -d)
  youtube-dl -f "bestaudio[ext=m4a]" --output "audio.m4a" "$1"
  youtube-cue --audio-file "audio.m4a" "$1" tracks.cue
  m4acut -C tracks.cue "audio.m4a" && \
  trash audio.m4a && \
  beet import -map .
}

HACKING

  • If it does not work on a specific video, please attach the complete output
  • Pull Requests are welcome that add support for a better parser without breaking the existing tests
  • Please add tests for any new functionality

License

Licensed under the MIT License

youtube-cue's People

Contributors

captn3m0 avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

youtube-cue's Issues

Timestamps larger than entire duration of youtube-video/audio-file

Example

https://www.youtube.com/watch?v=ENqiJKGT20Q

  • The timestamps of the last 2 tracks in the listing are later than the total duration of the video.
  • Youtube is aware of that, and those timestamps which lie outside of the video duration are just in black, are not blue and clickable anymore.

Thoughts

  • When manually checking the .CUE file output, you will notice that, and correct that manually.
  • Problematic is for automated scripts/pipes, where the cue-file is then handed over to mp3split or similar.
    • For this we could introduce --continue-on-duration-inconsistency
    • So the default is that the values must be consistent (to work well with as few arguments as possible) inside automated processes. But the possibility to suppress these.

Support non-Youtube sources

Since the core of the project is a generic timestamp parser to cue sheet generator, it might be helpful to support parsing text directly. Something like:

youtube-cue file.txt output.cue

Where file.txt contains:

[00:00:00] 1. Artist - Title
[00:02:53] 2. Artist - Title
[00:05:55] 3. Artist - Title
[00:08:49] 4. Artist - Title

And the cue sheet is generated accordingly.

youtube-cue not working for a DJ mix which has a tracklist in its description

Input

https://youtu.be/Yir4WyDi8rU is a DJ mix with a tracklist embedded somwhere in its description text. Structurally like this:

Some paragraphs of text. […]

Tracklist: 
[00:00:00] 1. Artist - Title
[00:02:53] 2. Artist - Title
[00:05:55] 3. Artist - Title
[00:08:49] 4. Artist - Title
[…]

Environment

macOS 11.4
youtube-cue 1.0.2

Attempts

I tried 3 different syntaxes (full youtube.com URL vs youtu.be short URL) and ("mix.cue" vs. literal "output.cue" as stated in --help)

test-yt-dl youtube-cue --audio-file "https://youtu.be/Yir4WyDi8rU" mix.cue
test-yt-dl youtube-cue --audio-file "https://youtube.com/watch?v=Yir4WyDi8rU" mix.cue 
test-yt-dl youtube-cue --audio-file "https://youtube.com/watch?v=Yir4WyDi8rU" output.cue

Expected

I get the cue-sheet or an error message which explains me why youtube-cue could not create a cue-sheet.

Actual

The result is always that the command line produces nothing but only outputs the "Usage" instructions. The same ones you get with --help.

Afterword

  • Excellent communication & support by the developer! As I am writing this issue, the previous three issues were already answered! So less speculation, more concrete, wonderful!
    • The app is supposed to support exactly that use case as confirmed by #60
    • There is no debug option yet according to #61 so what's above is all the input that I can provide for now.
    • Shortlinks are confirmed to be supported by #62
  • Will try to update to 1.0.3 and see if it works then.

Are tracks in a generated CUE sheet supposed to have START timestamps only or also END and DURATION ?

https://www.youtube.com/watch?v=Yir4WyDi8rU produces this CUE sheet: Running Mix 2020 135-160 BPM.cue.txt

When opening the MP3/CUE pair in VLC media player

  • Initially only the first track shows a duration.
  • When skipping through the tracks, the other tracks also update their duration info,
  • But those durations are all wrong, the duration of the individual tracks is falsely always the duration of the entire mix.
    Track start end duration - VLC playback init Track start end duration - VLC playback later

Now these raises the following questions

  • A proper CUE sheet, is it supposed to have START END DURATION time info for each track?
    • Logical thinking deduces this would be optimal, because then this info would be ready right after the player has read in the file
    • Of course END + DURATION of all songs but the last can easily be calculcated by substraction and addition.
    • But the last track END and DURATION would need to be calculcated against the length of the entire mix
      • either specified in the CUE sheet
      • or read out from the length of the audio file (UI needs to await processing of the media player first)
  • Or is the media player supposed to to that calculations?

Followup

  • If it is alright as it is (START only), then I may submit this as a bug/feature-proposal to VLC.
  • If a CUE sheet should have START END DURATION per each track, than youtube-cue should optimally do those calculations, and embedd that into the CUE sheet.

How do I get the debug log for youtube-cue ?

readme.md states:

If this video does not work on a specific video, please attach the debug log output.

But how do I get the debug?

  • --help does not tell me
  • there isn't a manpage
  • and also nothing in that regard in readme.md

Support tracklists with durations + arbitrary position of duration and tracknumber

Some tracklist come in this format:

TRACKLIST
1. Artist - Title - 6:19
2. Another Artist - Another Title - 6:59
3. Yet Another Artist - Yet another title - 5:12

In the majority of situations one can programmatically recognize that the given times are not points-in-time (indices) but durations, by checking these criteria:

  1. The first timestamp does not start at 00:00:00 or anywhere near it
    (given the offset of a few seconds which can sometimes occur due to gap corrections)
  2. If we have indeed point-in-times then the next track always must have a higher point-in-time. If it are durations it could be coincidence that each track is always a bit longer than the previous one. But statistically very unlikely. As soon as there are a few tracks on an album very very likely always one will be shorter than any of the previous songs. If only a single track is shorter than any previous one, we can be sure that these are durations rather than point-in-times.

So an algorithm should almost always auto-detect.
If not we could throw back an interactive question to the shell, and let the user decide.

Error: Could not automatically interpret the given timestamps.
Are these (p)oints-in-time or (d)urations ?
$ _

Parse Square brackets

Sample: https://youtu.be/Yir4WyDi8rU

[00:00:00] 1. Steve Kroeger x Skye Holland - Through The Dark 
[00:02:53] 2. Gabri Ponte x Jerome - Lonely 
[00:05:55] 3. Sander van Doorn x Harris & Ford - Spotlight 
[00:08:49] 4. Mariana BO & LaCrème - Red Eagle 
[00:11:48] 5. TJR - Shake That 

Support for music metadata recognized/provided by Youtube

Sample: https://www.youtube.com/watch?v=qclWIFxq2F4

Youtube with recognized music metadata 1 Youtube with recognized music metadata 2

If you open the video description, you get a specially formatted tracklisting provided by Youtube:

  • Either by their music recognition (via audio fingerprinting)
  • Or provided by the mix creator (and the licensees)

Pros and Cons

  • Title and artist very likely have a high accuracy
  • No time data there, but maybe it's provided by the endpoint/API?
  • No track numbers there, but they could be deduced simply by order, starting enumeration at 1.

Please add a clear description of what youtube-cue does and the requirements for a youtube-video in order to work

My intention is this

  • I download a DJ mix published on Youtube.
  • Somewhere in the description is a tracklisting with timecodes.
  • When triggering youtube-cue <output.cue> it downloads the metadata and runs a parser.
  • If that parser finds sufficient metadata it creates an output.cue
  • Then by help of other tools you download the audio track of a given youtube-URL, and according to the cue-sheet which youtube-cue produced, those tools cut the large mix down into the individual tracks, and individually change their filename and metadata (ID3).

Is this the intended purpose?

From the given name and description it sounds like that, but it is not explicitly telling this.
A clearer description would be appreciated.

Compliments to the maintainer!

@captn3m0 my compliments to you! 👍👍👍
Our feedback session today was very productive and felt very fulfilling to me!

  • Immediate response, immediate fixing: That feels very rewarding for someone providing input!
  • Good style of writing: Clear, concise, tags, followups.
    Also here: You know what's in scope, what not, and how things will continue! Very rewarding and motivating!

Thanks for your software and your great community support!

youtu.be shortlink support

Does youtube-cue support youtu.be/videoID shortlinks?

  • If yes, please mention it in the --help and in readme.md
  • If no, would be cool if support could be added.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.