mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-12-29 05:11:21 +00:00
Scrape YouTube by default and optionally use YouTube API to perform searches (#250)
* YouTube scraping * Cleanup GenerateYouTubeURL class * Some minor improvements * Add test to fetch title with and without api key
This commit is contained in:
@@ -120,6 +120,19 @@ def videotime_from_seconds(time):
|
||||
return '{0}:{1:02}:{2:02}'.format((time//60)//60, (time//60) % 60, time % 60)
|
||||
|
||||
|
||||
def get_sec(time_str):
|
||||
v = time_str.split(':', 3)
|
||||
v.reverse()
|
||||
sec = 0
|
||||
if len(v) > 0: # seconds
|
||||
sec += int(v[0])
|
||||
if len(v) > 1: # minutes
|
||||
sec += int(v[1]) * 60
|
||||
if len(v) > 2: # hours
|
||||
sec += int(v[2]) * 3600
|
||||
return sec
|
||||
|
||||
|
||||
def get_splits(url):
|
||||
if '/' in url:
|
||||
if url.endswith('/'):
|
||||
@@ -127,4 +140,4 @@ def get_splits(url):
|
||||
splits = url.split('/')
|
||||
else:
|
||||
splits = url.split(':')
|
||||
return splits
|
||||
return splits
|
||||
|
||||
Reference in New Issue
Block a user