-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTPSDistance.py
51 lines (42 loc) · 1.53 KB
/
TPSDistance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
#coding: utf-8
from pychord import Chord
import requests
from bs4 import BeautifulSoup
from cifra import Cifra
artist_url = "https://www.cifraclub.com.br/chico-buarque/"
artist_page = requests.get(artist_url)
soupArtist = BeautifulSoup(artist_page.text, 'lxml')
soup_songs_list = soupArtist.find(class_="list-links art_musics alf all")
soup_songs_links = soup_songs_list.find_all("a", class_="art_music-link")
links = []
for link in soup_songs_links:
links.append(link.get('href'))
problematic_chords = set()
problematic_songs = []
total_chords = 0
parsed_chords = 0
for link in links:
legivel = True
try:
cifra = Cifra("https://www.cifraclub.com.br" + link)
for chord in cifra.present_chords:
total_chords += 1
try:
ch = Chord(chord)
print(chord, ": ", ch.components())
parsed_chords += 1
except:
print("I see a ", chord, "chord on the title", link, ", but I can't read it! :(")
legivel = False
problematic_chords.append(chord)
problematic_songs.append(link)
except:
print("There are no chords here, pal.")
if (not legivel):
problematic_songs.append(link)
print("Total de acordes: ", total_chords)
print("Acordes legíveis: ", parsed_chords)
print("Taxa de aproveitamento: ", (parsed_chords/total_chords)*100, "%")
print("Problematic: ", problematic_songs)
print("Problematic Songs rate: ", len(problematic_songs)/len(links), "%")