leandertolksdorf / 1001-tracklists-api

Python library for easy access to data from 1001tracklists.com
MIT License
35 stars 8 forks source link

Added in Tracklist meta data feature #1

Closed AntonCitko closed 4 years ago

AntonCitko commented 4 years ago

Tracklist.fetch() will now also retrieve the meta data fro the tracklist by calling fetch_meta() get_meta() can be used to get the meta data in Tracklist objects

leandertolksdorf commented 4 years ago

When fetching this tracklist, I get the following error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "tracklists.py", line 68, in fetch self.meta = self.fetch_meta() File "tracklists.py", line 130, in fetch_meta meta_data["tracklist_likes"] = tracklist_interaction[1]["content"].split(":")[1]

That's because there's only one <meta itemprop="interactionCount" ... /> - tag on the page and you're assuming there are always two. Maybe better explicitly search for "UserPageVisits" and its equivalent for the tracklist likes in <meta itemprop="interactionCount" content="UserPageVisits:621">?

AntonCitko commented 4 years ago

When writing the feature I assumed likes and views would be always be on the page. Thank you for catching that it is not always there. I generalized the interaction fetching so that it will not have that problem. Also, in case they add user reposts, or something like that, it will be able to fetch it as well. Additionally, I added error handling in case other elements are missing on other tracklist pages or the pages change.

leandertolksdorf commented 4 years ago

Merged. Thank you for contributing! :yellow_heart: