Skip to content

Commit

Permalink
(-) Skipping song if unavailable (#100)
Browse files Browse the repository at this point in the history
* (-) Skipping song if unavailable

* (+) Preparing for impl of fetching unavailable data

* (~) Deleting else

* (-) Skipping song if unavailable

(+) Preparing for impl of fetching unavailable data

(~) Deleting else
  • Loading branch information
choppylion authored and python273 committed Nov 24, 2017
1 parent 13149b9 commit cde005c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions vk_api/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,24 @@ def scrap_data(html, user_id):
soup = BeautifulSoup(html, 'html.parser')
tracks = []
for audio in soup.find_all('div', {'class': 'audio_item'}):
ai_artist = audio.select('.ai_artist')
artist = ai_artist[0].text
if 'audio_item_disabled' in audio["class"]:
# TODO: implement getting data of unavailable track
continue

artist = audio.select('.ai_artist')[0].text
title = audio.select('.ai_title')[0].text
duration = audio.select('.ai_dur')[0]['data-dur']
track_id = audio['id']
link = audio.select('.ai_body')[0].input['value']

if 'audio_api_unavailable' in link:
link = decode_audio_url(link, user_id)

tracks.append({
'artist': artist,
'title': audio.select('.ai_title')[0].text,
'dur': audio.select('.ai_dur')[0]['data-dur'],
'id': audio['id'],
'title': title,
'dur': duration,
'id': track_id,
'url': link
})

Expand Down

0 comments on commit cde005c

Please sign in to comment.