Q:

Grab filename text between - and .mp3 and pipe into text file

I have a directory full of .mp3 files with filenames that contain a youtube link in it.  
All of the youtube watch URL parts in particular  start with a - and end with a .mp3. 
However, there is a problem. 
Some youtube links have -'s in them, and some of the titles have -'s in them too.  
I need to extract only this part of the video from the title:
https://www.youtube.com/watch?v=  (dQw4w9WgXcQ) 
The title of the video downloaded with youtube-dl is:
Rick Astley - Never Gonna Give You Up-dQw4w9WgXcQ.mp3
The title of the video is: 
Rick Astley - Never Gonna Give You Up
What I was trying to accomplish is to get all the links that I had already downloaded and put it in a text file that tells youtube-dl to not re-download them (download archive)
How would I go about doing this? ( preferably with a bash sed command, but at this point i am willing to try anything.) 

A:

it's easier than you think: the greedy .*  followed by - will eat all the -s until the last one:
# first get the titles an ids into a tab-separated multiline string
both=`find * -name "*.mp3" | sed 's/\(.*\)-\(.*\)\.mp3/\1\t\2/'`

# then cut it into two multiline strings
titles=`echo "$both" | cut -f1`
ids=`echo "$both" | cut -f2`

# or process each title-id pair one-by-one
echo "$both" | while IFS=$'\t' read title id; do
  echo "$title"
  echo "$id"
done

