Skip to content

Commit

Permalink
Fix episode and podcast search results
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Oct 21, 2024
1 parent 3345c07 commit a33c4f5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
9 changes: 5 additions & 4 deletions src/onthespot/api/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ def spotify_get_search_results(session, search_term, content_types):
},
headers={"Authorization": "Bearer %s" % token},
).json()

print(",".join(c_type for c_type in content_types))
print(data)
search_results = []

# Iterate over the keys in the response
Expand All @@ -425,15 +426,15 @@ def spotify_get_search_results(session, search_term, content_types):
item_name = item['name'] + f" | GENERES: {'/'.join(item['genres'])}"
item_by = f"{item['name']}"
item_thumbnail_url = item['images'][-1]["url"] if len(item['images']) > 0 else ""
elif item_type == "shows":
elif item_type == "show":
item_name = f"{config.get('explicit_label') if item['explicit'] else ''} {item['name']}"
item_by = f"{item['publisher']}"
item_thumbnail_url = item['images'][-1]["url"] if len(item['images']) > 0 else ""
elif item_type == "episodes":
elif item_type == "episode":
item_name = f"{config.get('explicit_label') if item['explicit'] else ''} {item['name']}"
item_by = ""
item_thumbnail_url = item['images'][-1]["url"] if len(item['images']) > 0 else ""
elif item_type == "audiobooks":
elif item_type == "audiobook":
item_name = f"{config.get('explicit_label') if item['explicit'] else ''} {item['name']}"
item_by = f"{item['publisher']}"
item_thumbnail_url = item['images'][-1]["url"] if len(item['images']) > 0 else ""
Expand Down
10 changes: 5 additions & 5 deletions src/onthespot/gui/mainui.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ def set_table_props(self):
window_width = self.width()
logger.info(f"Setting table item properties {window_width}")
# Sessions table
self.tbl_sessions.setSortingEnabled(True)
self.tbl_sessions.horizontalHeader().setSectionsMovable(True)
self.tbl_sessions.horizontalHeader().setSectionsClickable(True)
self.tbl_sessions.horizontalHeader().setSortIndicatorShown(True)
self.tbl_sessions.horizontalHeader().resizeSection(0, 16)
self.tbl_sessions.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch)
self.tbl_sessions.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeMode.Stretch)
Expand All @@ -423,18 +423,18 @@ def set_table_props(self):
self.tbl_sessions.horizontalHeader().setSectionResizeMode(5, QHeaderView.ResizeMode.Stretch)
self.tbl_sessions.horizontalHeader().setSectionResizeMode(6, QHeaderView.ResizeMode.Stretch)
# Search results table
self.tbl_search_results.setSortingEnabled(True)
self.tbl_search_results.horizontalHeader().setSectionsMovable(True)
self.tbl_search_results.horizontalHeader().setSectionsClickable(True)
self.tbl_search_results.horizontalHeader().setSortIndicatorShown(True)
self.tbl_search_results.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch)
self.tbl_search_results.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch)
self.tbl_search_results.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeMode.Stretch)
self.tbl_search_results.horizontalHeader().setSectionResizeMode(3, QHeaderView.ResizeMode.Stretch)
self.tbl_search_results.horizontalHeader().setSectionResizeMode(4, QHeaderView.ResizeMode.Stretch)
# Download progress table
self.tbl_dl_progress.setSortingEnabled(True)
self.tbl_dl_progress.horizontalHeader().setSectionsMovable(True)
self.tbl_dl_progress.horizontalHeader().setSectionsClickable(True)
self.tbl_dl_progress.horizontalHeader().setSortIndicatorShown(True)
if config.get("debug_mode"):
self.tbl_dl_progress.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Interactive)
else:
Expand Down Expand Up @@ -604,12 +604,12 @@ def fill_search_table(self):
self.tbl_search_results.removeRow(0)
search_term = self.inp_search_term.text().strip()
content_types = []
if self.inp_enable_search_tracks.isChecked():
content_types.append('track')
if self.inp_enable_search_playlists.isChecked():
content_types.append('playlist')
if self.inp_enable_search_albums.isChecked():
content_types.append('album')
if self.inp_enable_search_tracks.isChecked():
content_types.append('track')
if self.inp_enable_search_artists.isChecked():
content_types.append('artist')
if self.inp_enable_search_shows.isChecked():
Expand Down
10 changes: 5 additions & 5 deletions src/onthespot/gui/qtui/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<string notr="true"/>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="search">
<attribute name="title">
Expand Down Expand Up @@ -231,7 +231,7 @@
<string>Episodes</string>
</property>
<property name="checked">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -241,7 +241,7 @@
<string>Podcasts</string>
</property>
<property name="checked">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -251,7 +251,7 @@
<string>Audiobooks</string>
</property>
<property name="checked">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand Down Expand Up @@ -569,7 +569,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-1370</y>
<y>0</y>
<width>631</width>
<height>3181</height>
</rect>
Expand Down
2 changes: 1 addition & 1 deletion src/onthespot/otsconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, cfg_path=None):
"language": "en_US", # Language
"language_index": 0, # Language Index
"max_threads": 1, # Maximum number of thread we can spawn
"parsing_acc_sn": 1, # Serial number of account that will be used for parsing links
"parsing_acc_sn": 0, # Serial number of account that will be used for parsing links
"rotate_acc_sn": False, # Rotate active account for parsing and downloading tracks
"download_root": os.path.join(os.path.expanduser("~"), "Music", "OnTheSpot"), # Root dir for downloads
"download_delay": 3, # Seconds to wait before next download attempt
Expand Down
2 changes: 1 addition & 1 deletion src/onthespot/parse_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def parse_url(url):
accounts = config.get('accounts')
account_service = accounts[config.get('parsing_acc_sn') - 1]['service']
account_service = accounts[config.get('parsing_acc_sn')]['service']
if account_service == 'soundcloud' and re.match(SOUNDCLOUD_URL_REGEX, url):
item_type, item_id = soundcloud_parse_url(url)
item_service = "soundcloud"
Expand Down
2 changes: 1 addition & 1 deletion src/onthespot/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ def get_search_results(search_term, content_types=None):
logger.info(f"Search clicked with value term {search_term}")
if search_term != "":
token = get_account_token()
account_type = config.get('accounts')[config.get('parsing_acc_sn') - 1]['service']
account_type = config.get('accounts')[config.get('parsing_acc_sn')]['service']
return globals()[f"{account_type}_get_search_results"](token, search_term, content_types)

0 comments on commit a33c4f5

Please sign in to comment.