Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
seanfhear committed May 29, 2019
1 parent fe6bbf8 commit 044593f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
SEARCH_URL = "https://www.ultimate-guitar.com/search.php?page={}&search_type=title&value={}"
RESULTS_PATTERN = "\"results\":(\[.*?\]),\"pagination\""
RESULTS_COUNT_PATTERN = "\"tabs\",\"results_count\":([0-9]+?),\"results\""
DOWNLOAD_TIMEOUT = 15


def search_tabs(search_string, types):
Expand Down Expand Up @@ -154,9 +155,9 @@ def download_file(url, tab_type, artist):
'or text()="DOWNLOAD Power TAB"]')
driver.execute_script("arguments[0].click();", button)

# kill firefox process after 10 seconds to give time for download
# kill firefox process after download completes or a timeout is reached
downloading = True
timeout = 15
timeout = DOWNLOAD_TIMEOUT
while downloading and timeout > 0:
sleep(0.5)
if len(os.listdir(destination)) > nFiles:
Expand Down

0 comments on commit 044593f

Please sign in to comment.