Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
UI Changes (by bascurtiz), improvements to matching
Browse files Browse the repository at this point in the history
  • Loading branch information
Marekkon5 committed Nov 2, 2020
1 parent 56f9f35 commit 0c1bf92
Show file tree
Hide file tree
Showing 6 changed files with 265 additions and 146 deletions.
27 changes: 24 additions & 3 deletions beatport.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ def match_track(self, title: str, artists: list, fuzzywuzzy_ratio = 80):
tracks = self.search_tracks(query)

clean_title = self._clean_title(title)
#Add original mix if not mix
if '(' and ')' in title:
clean_title_om = clean_title
else:
clean_title_om = self._clean_title(title + ' (Original Mix)')
clean_artists = self._clean_artists(artists)

fuzzy_matches = []
for track in tracks:
#Match title
if clean_title == self._clean_title(track.title) or clean_title == self._clean_title(track.name):
if clean_title == self._clean_title(track.title) or clean_title_om == self._clean_title(track.name):
#Match single artists
bp_artists = [self._clean_artist(a.name) for a in track.artists]
for artist in artists:
Expand All @@ -46,10 +52,25 @@ def match_track(self, title: str, artists: list, fuzzywuzzy_ratio = 80):
return track

#No match - use fuzzywuzzy
if fuzz.token_sort_ratio(track.title, title) >= fuzzywuzzy_ratio:
fuzzy = fuzz.token_sort_ratio(track.title.replace('(Original Mix)', ''), title.replace('(Original Mix)', ''))
if fuzzy >= fuzzywuzzy_ratio:
#Fuzzy match all artists
bp_artists = ','.join([a.name for a in track.artists])
if fuzz.token_sort_ratio(','.join(artists), bp_artists) >= fuzzywuzzy_ratio:
return track
fuzzy_matches.append((fuzzy, track))
continue
#Match single exact artist
bp_artists = [self._clean_artist(a.name) for a in track.artists]
for artist in artists:
if self._clean_artist(artist) in bp_artists:
fuzzy_matches.append((fuzzy, track))
continue

#Get best fuzzy match
fuzzy_matches.sort(key=lambda i: i[0], reverse=True)
if len(fuzzy_matches) > 0:
return fuzzy_matches[0][1]


def _remove_special(self, input: str) -> str:
specials = '.,()[] &_"' + "'"
Expand Down
8 changes: 4 additions & 4 deletions beatporttagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def update(self):
window = webview.create_window(
'Beatport Tagger',
'html/index.html',
resizable=True,
width=420,
height=860,
min_size=(420, 420),
resizable=False,
width=435,
height=800,
min_size=(435, 800),
js_api=JSAPI()
)

Expand Down
126 changes: 65 additions & 61 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,94 +13,98 @@ <h1>Beatport Tagger</h1>
<div class='content'>
<h2>INPUT</h2>
<div>
<input type='text' id='path' class='path-input'>
<button onclick='browse()' style="margin-left: 11px;">BROWSE</button>
<input type="text" id="path" class="path-input">
<button onclick="browse()" style="margin-left: 10px;">BROWSE</button>
</div>
<h2>SETTINGS</h2>
<div class="checkbox-container circular-container">
<label class='checkbox-label'>&nbsp; &nbsp;&nbsp;
<input type='checkbox' id='replaceArt'>
<label for='replaceArt' class='checkbox-label'>Replace Album Art</label>
<span class='checkbox-custom circular'></span>
<label class="checkbox-label">&nbsp; &nbsp;&nbsp;
<input type="checkbox" id="replaceArt">
<label for="replaceArt" class="checkbox-label">Replace
Album Art
</label>
<span class="checkbox-custom circular"></span>
</label>
</div>
<div class='text-input'>
<label for='artResolution'>Album Art Resolution:</label>
<input type='number' id='artResolution' value='1000' min='100' max='3000' step='100'>
<div class="text-input">
<label for="artResolution">Album Art Resolution:</label>
<input type="number" id="artResolution" value="1000" min="100" max="3000" step="100">
</div>
<div class='text-input'>
<label for='artistSeparator'>Artist Separator:</label>
<input type='text' id='artistSeparator' value='; '>
<div class="text-input">
<label for="artistSeparator">Artist Separator:</label>
<input type="text" id="artistSeparator" value="; ">
</div>
<div class='text-input'>
<label for='fuzziness'>Fuzziness (%):</label>
<input type='number' id='fuzziness' value='90' min='10' max='100' step='1'>
<div class="text-input">
<label for="fuzziness">Fuzziness (%):</label>
<input type="number" id="fuzziness" value="81" min="10" max="100" step="1">
</div>
<h2>TAGS</h2>
<div class="checkbox-container circular-container">
<label class='checkbox-label'>&nbsp; &nbsp;&nbsp;
<input type='checkbox' id='updateTitle'>
<label for='updateTitle' class='checkbox-label'>Title</label>
<span class='checkbox-custom circular'></span>
<div class="checkbox-container-edit circular-container">
<label class="checkbox-label">&nbsp; &nbsp;&nbsp;
<input type="checkbox" id="updateTitle">
<label for="updateTitle" class="checkbox-label">Title</label>
<span class="checkbox-custom circular"></span>
</label>
</div>
<div class="checkbox-container circular-container">
<label class='checkbox-label'>&nbsp; &nbsp;&nbsp;
<input type='checkbox' id='updateArtists'>
<label for='updateArtists' class='checkbox-label'>Artists</label>
<span class='checkbox-custom circular'></span>
<div class="checkbox-container-edit circular-container">
<label class="checkbox-label">&nbsp; &nbsp;&nbsp;
<input type="checkbox" id="updateArtists">
<label for="updateArtists" class="checkbox-label">Artists</label>
<span class="checkbox-custom circular"></span>
</label>
</div>
<div class="checkbox-container circular-container">
<label class='checkbox-label'>&nbsp; &nbsp;&nbsp;
<input type='checkbox' id='updateAlbum'>
<label for='updateAlbum' class='checkbox-label'>Album</label>
<span class='checkbox-custom circular'></span>
<div class="checkbox-container-edit circular-container">
<label class="checkbox-label">&nbsp; &nbsp;&nbsp;
<input type="checkbox" id="updateAlbum">
<label for="updateAlbum" class="checkbox-label">Album</label>
<span class="checkbox-custom circular"></span>
</label>
</div>
<div class="checkbox-container circular-container">
<label class='checkbox-label'>&nbsp; &nbsp;&nbsp;
<input type='checkbox' id='updateLabel'>
<label for='updateLabel' class='checkbox-label'>Label</label>
<span class='checkbox-custom circular'></span>
<div class="checkbox-container-edit circular-container">
<label class="checkbox-label">&nbsp; &nbsp;&nbsp;
<input type="checkbox" id="updateLabel">
<label for="updateLabel" class="checkbox-label">Label</label>
<span class="checkbox-custom circular"></span>
</label>
</div>
<div class="checkbox-container circular-container">
<label class='checkbox-label'>&nbsp; &nbsp;&nbsp;
<input type='checkbox' id='updateBPM'>
<label for='updateBPM' class='checkbox-label'>BPM</label>
<span class='checkbox-custom circular'></span>
<div class="checkbox-container-edit circular-container">
<label class="checkbox-label">&nbsp; &nbsp;&nbsp;
<input type="checkbox" id="updateBPM">
<label for="updateBPM" class="checkbox-label">BPM</label>
<span class="checkbox-custom circular"></span>
</label>
</div>
<div class="checkbox-container circular-container">
<label class='checkbox-label'>&nbsp; &nbsp;&nbsp;
<input type='checkbox' id='updateGenre' checked>
<label for='updateGenre' class='checkbox-label'>Genre</label>
<span class='checkbox-custom circular'></span>
<div class="checkbox-container-edit circular-container">
<label class="checkbox-label">&nbsp; &nbsp;&nbsp;
<input type="checkbox" id="updateGenre" checked="">
<label for="updateGenre" class="checkbox-label">Genre</label>
<span class="checkbox-custom circular"></span>
</label>
</div>
<div class="checkbox-container circular-container">
<label class='checkbox-label'>&nbsp; &nbsp;&nbsp;
<input type='checkbox' id='updateDate'>
<label for='updateDate' class='checkbox-label'>Date / Year</label>
<span class='checkbox-custom circular'></span>
<div class="checkbox-container-edit circular-container">
<label class="checkbox-label">&nbsp; &nbsp;&nbsp;
<input type="checkbox" id="updateDate">
<label for="updateDate" class="checkbox-label">Release Date</label>
<span class="checkbox-custom circular"></span>
</label>
</div>
<div class="checkbox-container circular-container">
<label class='checkbox-label'>&nbsp; &nbsp;&nbsp;
<input type='checkbox' id='updateKey'>
<label for='updateKey' class='checkbox-label'>Key</label>
<span class='checkbox-custom circular'></span>
<div class="checkbox-container-edit circular-container">
<label class="checkbox-label">&nbsp; &nbsp;&nbsp;
<input type="checkbox" id="updateKey">
<label for="updateKey" class="checkbox-label">Key</label>
<span class="checkbox-custom circular"></span>
</label>
</div>
</div>
<button class='start-button' onclick='start()' style="line-height: 25px;" id='startButton'>START</button>
<br>
<progress id='progress' class='progress' value='0' max='100'></progress>
<button class='start-button' onclick='start()' style="line-height: 20px;" id='startButton'>START</button>
<br>
<br>
<div>
<span style="color: #8C8C8C; font-family: 'Open Sans', sans-serif; font-weight: 400;">PROGRESS: <span id="percent">0</span>%&nbsp; |&nbsp; SUCCESSFUL: <span id="success">0</span>&nbsp; |&nbsp;&nbsp; FAILED: <span id="failed">0</span></span>
<div class='bottom-bar'>
<progress id='progress' class='progress' value='0' max='100'></progress>
<br>
<br>
<div class='progression'>
<span>PROGRESS: <span id="percent">0</span>%&nbsp; &nbsp; SUCCESSFUL: <span id="success">0</span>&nbsp; &nbsp; FAILED: <span id="failed">0</span></span>
</div>
</div>
</body>
<script>
Expand Down
Loading

0 comments on commit 0c1bf92

Please sign in to comment.