iheanyi / bandcamp-dl

Simple python script to download Bandcamp albums
The Unlicense
941 stars 104 forks source link

Track lyrics not being embedded when downloading track URLS #186

Closed arogl closed 2 years ago

arogl commented 3 years ago

Describe the bug When embedding lyrics for a track download, the embed fails

To Reproduce Command to reproduce the behavior: bandcamp-dl -d -e -r -k -u

https://meganmcduffee.bandcamp.com/track/relax

Expected behavior Lyrics do exist on the track and should be embedded

Logs Most if not always you will get some kind of output explaining the issue, post it:

arogl > bandcamp-dl -d -e -r -k -u https://meganmcduffee.bandcamp.com/track/relax
DEBUG:root:
        URL: https://meganmcduffee.bandcamp.com/track/relax
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): meganmcduffee.bandcamp.com:443
DEBUG:urllib3.connectionpool:https://meganmcduffee.bandcamp.com:443 "GET /track/relax HTTP/1.1" 200 None
DEBUG:root: Generating BandcampJSON..
DEBUG:root: Grab pagedata JSON..
DEBUG:root: Grabbing embedded scripts..
DEBUG:root: Converting JS to JSON..
DEBUG:root: Converting JS to JSON..
DEBUG:root: BandcampJSON generated..
DEBUG:root: Generating Album..
DEBUG:root: Fetching track lyrics..
Traceback (most recent call last):
  File "/home/arogl/.local/bin/bandcamp-dl", line 8, in <module>
    sys.exit(main())
  File "/home/arogl/.local/lib/python3.8/site-packages/bandcamp_dl/__main__.py", line 100, in main
    albumList.append(bandcamp.parse(url, not arguments['--no-art'], arguments['--embed-lyrics'], arguments['--debug']))
  File "/home/arogl/.local/lib/python3.8/site-packages/bandcamp_dl/bandcamp.py", line 77, in parse
    track['lyrics'] = self.get_track_lyrics("{}{}#lyrics".format(artist_url, track['title_link']))
  File "/home/arogl/.local/lib/python3.8/site-packages/bandcamp_dl/bandcamp.py", line 93, in get_track_lyrics
    track_page = requests.get(track_url, headers=self.headers)
  File "/home/arogl/.local/lib/python3.8/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/home/arogl/.local/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/arogl/.local/lib/python3.8/site-packages/requests/sessions.py", line 528, in request
    prep = self.prepare_request(req)
  File "/home/arogl/.local/lib/python3.8/site-packages/requests/sessions.py", line 456, in prepare_request
    p.prepare(
  File "/home/arogl/.local/lib/python3.8/site-packages/requests/models.py", line 316, in prepare
    self.prepare_url(url, params)
  File "/home/arogl/.local/lib/python3.8/site-packages/requests/models.py", line 390, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL '/track/relax#lyrics': No schema supplied. Perhaps you meant http:///track/relax#lyrics?

Working showing lyrics exist

arogl > bandcamp-dl -d -r -k -u https://meganmcduffee.bandcamp.com/track/relax
DEBUG:root:
        URL: https://meganmcduffee.bandcamp.com/track/relax
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): meganmcduffee.bandcamp.com:443
DEBUG:urllib3.connectionpool:https://meganmcduffee.bandcamp.com:443 "GET /track/relax HTTP/1.1" 200 None
DEBUG:root: Generating BandcampJSON..
DEBUG:root: Grab pagedata JSON..
DEBUG:root: Grabbing embedded scripts..
DEBUG:root: Converting JS to JSON..
DEBUG:root: Converting JS to JSON..
DEBUG:root: BandcampJSON generated..
DEBUG:root: Generating Album..
DEBUG:root: Generating track metadata..
DEBUG:root: Track metadata generated..
DEBUG:root: Album generated..
DEBUG:root: Album URL: https://meganmcduffee.bandcamp.com/track/relax
DEBUG:root: Album data:
        {'tracks': [{'duration': 211.744, 'track': 'None', 'title': 'Relax', 'url': 'https://t4.bcbits.com/stream/e13d6ec8e02e72fd2a65c882192f9ecd/mp3-128/2315078460?p=0&ts=1625562911&t=7f92f7b8981b8951c1af5dd61a81d5c476186100&token=1625562911_4300df179871ae6ebc3650ef477aaf972e787268', 'lyrics': 'Come in and put your weary feet up,\r\nCome in and gently close the door.\r\nOur time will leave you intrigued,\r\nAnd wanting more.\r\n\r\nRemove your clothes,\r\nListen to those headphones.\r\nTake off your pants,\r\nrelax.\r\n \r\nNo better time to take a short break,\r\nNo better time to close your eyes.\r\nJust let go of the old way,\r\ncomfort lies inside.\r\n\r\nRemove your clothes,\r\nListen to those headphones.\r\nTake off your pants,\r\nrelax.\r\n\r\nAll this new silence,\r\nRoom to meditate.\r\nNo judgement, no fear,\r\nIt’d be so easy to stay.\r\n\r\nEscape into a new era,\r\nEscape can be within your mind.\r\nSo plug in, take a deep breath,\r\nAnd you’ll become mine.\r\n\r\nRemove your clothes,\r\nListen to those headphones.\r\nTake off your pants,\r\nrelax.\r\n\r\nRemove your clothes,\r\nListen to those headphones.\r\nTake off your pants,\r\nrelax.'}], 'title': 'Relax', 'artist': 'Megan McDuffee', 'label': 'Megan McDuffee', 'full': True, 'art': 'https://f4.bcbits.com/img/a1976944547_10.jpg', 'date': '2020', 'url': 'https://meganmcduffee.bandcamp.com/track/relax'}
DEBUG:root:Preparing download process..
DEBUG:root:Initiating download process..
DEBUG:root: Generating filepath/trackname..
DEBUG:root: filepath/trackname generated..
DEBUG:root:
        Path: /mnt/h/New_Music/import/meganmcduffee/Megan McDuffee/Relax/Single - Relax.mp3
DEBUG:root: Directory:
        /mnt/h/New_Music/import/meganmcduffee/Megan McDuffee/Relax
DEBUG:root: Directory doesn't exist, creating..
DEBUG:root: Current file:
        /mnt/h/New_Music/import/meganmcduffee/Megan McDuffee/Relax/Single - Relax.mp3.tmp
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): f4.bcbits.com:443
DEBUG:urllib3.connectionpool:https://f4.bcbits.com:443 "GET /img/a1976944547_10.jpg HTTP/1.1" 200 449316
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): t4.bcbits.com:443
DEBUG:urllib3.connectionpool:https://t4.bcbits.com:443 "GET /stream/e13d6ec8e02e72fd2a65c882192f9ecd/mp3-128/2315078460?p=0&ts=1625562911&t=7f92f7b8981b8951c1af5dd61a81d5c476186100&token=1625562911_4300df179871ae6ebc3650ef477aaf972e787268 HTTP/1.1" 200 3388812
DEBUG:root: Encoding process starting..
DEBUG:root: Encoding process finished..
DEBUG:root: Renaming:
        /mnt/h/New_Music/import/meganmcduffee/Megan McDuffee/Relax/Single - Relax.mp3.tmp -to-> /mnt/h/New_Music/import/meganmcduffee/Megan McDuffee/Relax/Single - Relax.mp3

If possible after running the command with the --debug option.

Desktop (please complete the following information):

Evolution0 commented 3 years ago

Yeah that's weird, I'll look into that.

Its likely that I never tested it against actual singles and treating every track as part of an album in the code is now causing issues as I expected.

Evolution0 commented 2 years ago

Fixed in 0.0.11, releasing soon:tm:

I was right, I assumed every URL would have album in its string as I coded that bit of logic long before I found out about singles.