-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
217 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,4 +40,6 @@ bld/ | |
[Oo]ut/ | ||
msbuild.log | ||
msbuild.err | ||
msbuild.wrn | ||
msbuild.wrn | ||
|
||
Songs/ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-7.77 KB
SoulseekAPI/.vs/SoulseekAPI/FileContentIndex/289600c7-cf69-4a0c-8fe9-80a7cd7cdb1e.vsidx
Binary file not shown.
Binary file added
BIN
+12.6 KB
SoulseekAPI/.vs/SoulseekAPI/FileContentIndex/3ff90b5a-1400-4023-a96f-8058a779e2f2.vsidx
Binary file not shown.
Binary file removed
BIN
-12.5 KB
SoulseekAPI/.vs/SoulseekAPI/FileContentIndex/806c0005-acc0-44b4-8341-abbaaf280ffe.vsidx
Binary file not shown.
Binary file added
BIN
+11.4 KB
SoulseekAPI/.vs/SoulseekAPI/FileContentIndex/a3a1c70b-a4e8-4d62-a65d-5ac4efae7cd0.vsidx
Binary file not shown.
Binary file added
BIN
+11 KB
SoulseekAPI/.vs/SoulseekAPI/FileContentIndex/e9842686-97d7-461d-924d-b4478f771ae3.vsidx
Binary file not shown.
Binary file removed
BIN
-10.3 KB
SoulseekAPI/.vs/SoulseekAPI/FileContentIndex/ffd2401b-4115-41c5-9eb2-ec4abddc8670.vsidx
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import time | ||
import requests | ||
from requests import ConnectTimeout | ||
|
||
import util.printWithColors as printColor | ||
import util.colors as colors | ||
|
||
BASE_URL_API = "https://localhost:7069" | ||
TIMEOUT_IN_SECONDS = (5 * 60) # 5 Minutes | ||
|
||
|
||
def search_for_song(index, artist, song, filter_type, exclude, min_size, max_size): | ||
printColor.blue(f'{index}: Searching for {song} by {artist}...') | ||
headers = { | ||
"Accept": 'Application/json' | ||
} | ||
|
||
try: | ||
start = time.time() | ||
req = requests.get( | ||
url=f'{BASE_URL_API}/SoulseekSongs' | ||
f'?song={song}&artist={artist}&filterType={filter_type}&exclude={exclude}&minSize={min_size}', | ||
headers=headers, | ||
verify=False, | ||
timeout=TIMEOUT_IN_SECONDS | ||
) | ||
end = time.time() | ||
if req.status_code == 200: | ||
response = req.json() | ||
if len(response) != 0: | ||
printColor.green(f'Success: Found {len(response)} songs in {round(end - start, 2)} seconds') | ||
return response[0] | ||
else: | ||
printColor.red(f'Could not find {song} by {artist}') | ||
return None | ||
else: | ||
printColor.red(f'Could not find any results for {song} by {artist}, got {req.status_code}') | ||
return None | ||
except ConnectTimeout: | ||
printColor.red(f'Could not find any results for {song} by {artist}, ConnectTimeout') | ||
return None | ||
except Exception: | ||
printColor.red("Something went wrong with searching for songs") | ||
|
||
|
||
def download_song(song, folder_name): | ||
print(f'Downloading {colors.GREEN}{song["name"]}{colors.ENDC}') | ||
|
||
try: | ||
start = time.time() | ||
req = requests.post( | ||
url=f'{BASE_URL_API}/SoulseekSongs?folder={folder_name}', | ||
json=song, | ||
verify=False, | ||
timeout=TIMEOUT_IN_SECONDS | ||
) | ||
end = time.time() | ||
|
||
if req.status_code == 200: | ||
printColor.green(f'Success: Downloaded {song["name"]} in {round(end - start, 2)} seconds') | ||
else: | ||
printColor.red( | ||
f'Could not download {song["name"]} in {round(end - start, 2)} seconds, got {req.status_code}') | ||
except ConnectTimeout: | ||
printColor.red(f'Could not download song {song["name"]}, ConnectTimeout') | ||
except Exception: | ||
printColor.red(f'Something went wrong with downloading song {song["name"]}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from datetime import datetime | ||
import util.colors as colors | ||
import util.printWithColors as printColor | ||
|
||
|
||
def get_date_and_time(): | ||
return datetime.now().strftime("%d%m%Y_%H.%M.%S") | ||
|
||
|
||
def finished_print(diff): | ||
printColor.blue(f'Finished! Total time: {round(diff, 2)} s. ({round(diff / 60, 2)} min.)') | ||
|
||
|
||
def print_spotify_details(total_tracks, playlist_name, owner, playlist_txt_file, playlist_json_file): | ||
print( | ||
f'\n\nFound {colors.GREEN}{total_tracks}{colors.ENDC} tracks in the playlist ' | ||
f'{colors.GREEN}{playlist_name}{colors.ENDC} made by ' | ||
f'{colors.BLUE}{owner}{colors.ENDC} on {colors.GREEN}Spotify{colors.ENDC}\n' | ||
f'Playlist tracks in text format can be found in {colors.BLUE}{playlist_txt_file}{colors.ENDC}\n' | ||
f'Playlist tracks in JSON format can be found in {colors.BLUE}{playlist_json_file}{colors.ENDC}\n' | ||
) |