Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate playlists from songs listed in video descriptions #642 #649

Merged
merged 8 commits into from Jun 16, 2017

Conversation

tommysolsen
Copy link
Member

As discussed in PR #642, I've extended the mkp function to allow users to make playlists from text found in video descriptions.

I have had the results pop up in a listview, so the user can inspect the parse before committing it to a playlist. Like any playlist selection, the user can select using numbers and ranges which songs they want to include in their playlist.

Finally I did some minor pylinting on the generate_playlist file.

record

ListView file was getting somewhat large, I wanted to split it up into separate files to make it easier to find the applicable datatype.
fetch_songs uses a series of regex expressions to filter out
"artist - title" combinations from mixed text input.
Old generate_playlist function only used random playlist names.
Defaults to random if no title is specified.
Extends mkp functionality by having it act on the --description parameter.

When the --description parameter is passed, the software looks through g.model for suitable datatypes. It will find the first applicable object based on numerical input from the user, download that videos description and parse it for artist - track combinations, and will store that in a local playlist using the existing generate_playlist functionality.
Adds mkp to the search helptext keywords, adds --description help text.

Changed some _len(varname) > 0:_ as this is the same as _if varname:_
@tommysolsen tommysolsen changed the title Description playlist gen Generate playlists from songs listed in video descriptions #642 Jun 14, 2017
@ids1024
Copy link
Contributor

ids1024 commented Jun 14, 2017

Videos with track lists in the description generally have all those songs in them, right? So the point here is to find alternate versions that are individual tracks, so you can treat them as individual tracks?

create_playlist(idx, title)

data = [listview.ListSongtitle(x) for x in data]
g.content = listview.ListView(columns, data, run_m)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to result in a No objects in list exception in some cases; I guess len(data) needs to be checked?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I guess if the software is unable to find any tracks, it would throw exceptions. I'll add a check for that.

@rocketinventor
Copy link

Documentation?

@ids1024
Copy link
Contributor

ids1024 commented Jun 14, 2017

This seems like a fairly useful feature in certain cases; making it work reliably is difficult though. It seems to result in nonsense for videos that don't have track listings in their descriptions; perhaps that is acceptable, but it might be better to look for certain patterns and only match if it seems to have a track listing. That could potentially reduce the number of cases it matches successfully on, though.

It also isn't working too consistently; videos like https://youtube.com/watch?v=_-sYj_1lADo don't match correctly even though there is a track listing. Ultimately there's a limit to how reliable it can be without hard AI though.

@ids1024
Copy link
Contributor

ids1024 commented Jun 14, 2017

One thing to do is to check for lines starting with times; those are a good indicator for a track listing.

@tommysolsen
Copy link
Member Author

tommysolsen commented Jun 14, 2017

@ids1024 Yeah, correct. My personal use case was with EDM or other mixes where songs are often mashed together and/or mixed together to a coherent long mix, so if I find songs I like in a mix and want to listen to them with their proper start and end, I need to search for them separately.

I didn't include straight up album searches, because we can already do that with the album command. Currently I use dashes to look for artist - track title like strings and use them, but i realize that does leave it unable to recognize single band mixtapes and such where the timestamp can be ommited and you only list titles. I am stumped on how to make it reliable. I guess most mixes do include timestamps, but I found a fair few that don't. Thumbs up for Rush!

@rocketinventor Sorry, I'm new to all of this, anything in particular I should document?

@ids1024
Copy link
Contributor

ids1024 commented Jun 14, 2017

Yeah, albums are not the most useful example since album exists, but that was the easiest thing to test it with.

I don't know how reliable this can be made; it is expected that it will no be entirely reliable. But some things to try:

  • If there is a series of lines starting with times, take that as the track listing and use those with the times stripped (possibly using the times to match, though those usually are the time in the video, so they would need to be subtracted to get durations)
  • Try to support lists without dashes; a playlist of tracks by a single artist won't have the artist name
  • Any other tricks

@rocketinventor
Copy link

For the regex, first check for (0-1) matches that look like a timestamp, than match for the song info after that. It might be a good idea to tie into some sort of music database and search that to figure out the exact song metadata. There is no guarantee that song info will be in any specific order or format.

@rocketinventor
Copy link

@Razesdark I would add something to the Readme explaining that this feature exists and explain the steps that need to be taken to use this feature (i.e. the commands that you typed in the gif that you shared).

@rocketinventor
Copy link

I noticed that there is some explanation of this feature at #642 but there is no mention of this feature in the Readme. New users will likely be unaware of this feature.

@tommysolsen
Copy link
Member Author

tommysolsen commented Jun 15, 2017

Ok, here is a updated version of the code.

It tries to check each line and come up with a confidence index for wether or not it thinks the line is a song title or not.
Its based on a few factors, like does the line start with a number, does it look like a artist - track combination or does it have a time stamp.

Then it takes the lines with an index above average, which I feel works because tracklisting formatting is usually consistent so all lines should be equally above average, as long as there is one line or more weighing down the average.

Once it has the list that it percieves as song titles, it tries to determine if the line has the artist in it or not. Checks wether or not the results are consistent, removes inconsistent results if they are few, or exits if it finds too many of them.

If it needs to find the artist name, it tries to parse the title by doing a youtube search on the title, then tries to repeatedly find the most frequent common string between a random subset of the results. Most of the time I tried this, it would only return the correct name, but sometimes it would have several results. (Like Best of, Album titles, etc), in the case of several alternatives, it will use the one that matches first in the original title. As I expect that the most common setup would be Artist name first.

@rocketinventor
Copy link

@Razesdark Nice Work!

@ids1024 ids1024 merged commit 3e885b6 into mps-youtube:develop Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants