Skip to content

Commit

Permalink
Rename versions->alternatives and hide Official chords in alternatives
Browse files Browse the repository at this point in the history
  • Loading branch information
kmille committed Jun 25, 2024
1 parent 1e5d9f2 commit e19605d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions freetar/templates/tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ <h5><a href="/search?search_term={{ tab.artist_name }}">{{ tab.artist_name }}</a
</div>

<a class="d-print-none d-block d-md-none mt-4" href="{{ tab.tab_url }}">View on Ultimate Guitar</a>
{% if tab.versions %}
{% if tab.alternatives %}
<div class="d-print-none mt-4">
<h2>Alternative versions</h2>
<ul class="list-unstyled">
{% for version in tab.versions %}
<li><a href="{{ version.tab_url }}">
Version {{ version.version }} ({{ version._type }}) {{version.rating }}/5 ({{ version.votes }})
{% for alt in tab.alternatives %}
<li><a href="{{ alt.tab_url }}">
Version {{ alt.version }} ({{ alt._type }}) {{alt.rating }}/5 ({{ alt.votes }})
</a></li>
{% endfor %}
</ul>
Expand Down
9 changes: 5 additions & 4 deletions freetar/ug.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SongDetail():
capo: str
tuning: str
tab_url: str
versions: list[SearchResult] = field(default_factory=list)
alternatives: list[SearchResult] = field(default_factory=list)

def __init__(self, data):
if __name__ == '__main__':
Expand All @@ -65,9 +65,10 @@ def __init__(self, data):
_tuning = data["store"]["page"]["data"]["tab_view"]["meta"].get("tuning")
self.tuning = f"{_tuning['value']} ({_tuning['name']})" if _tuning else None
self.tab_url = data["store"]["page"]["data"]["tab"]["tab_url"]
self.versions = []
for version in data["store"]["page"]["data"]["tab_view"]["versions"]:
self.versions.append(SearchResult(version))
self.alternatives = []
for alternative in data["store"]["page"]["data"]["tab_view"]["versions"]:
if alternative.get("type", "") != "Official":
self.alternatives.append(SearchResult(alternative))
self.fix_tab()

def __repr__(self):
Expand Down

0 comments on commit e19605d

Please sign in to comment.