-
Notifications
You must be signed in to change notification settings - Fork 9
feat(myinstants): MyInstants Integration #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
2fadf24
feat(myinstants): MyInstants Integration
Dolly132 e136ec7
fix linting issues
Dolly132 37cdd8f
aa
Dolly132 5461115
PLEASE
Dolly132 f311bd9
Update MyInstants.py
Dolly132 0b0ee6e
ruff please
Dolly132 1a2ef91
wow
Dolly132 23082e9
yes finally
Dolly132 7eec6b4
Update Commands.py
Dolly132 5b5f780
FOR REAL RUFF?
Dolly132 099a72e
please
Dolly132 11ac890
s
Dolly132 1dc717f
i guess it should be GOOD NOW?
Dolly132 d9d62b2
Merge branch 'master' into main-dolly9
Dolly132 52a2e84
add proxy support
Dolly132 67b6f99
resolved copilot suggestions
Dolly132 c011060
aa
Dolly132 fdd85d0
smh
Dolly132 386c244
a
Dolly132 9568f47
resolve copilot suggestion
Dolly132 7e87c8a
a
Dolly132 8a12737
Merge branch 'main-dolly9' of https://github.com/Dolly132/torchlight …
Dolly132 1ab210a
Bump version to 1.5.0
Rushaway da52a8f
Merge branch 'master' into main-dolly9
Rushaway File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,52 @@ | ||
| import re | ||
| import secrets | ||
| from urllib.parse import urljoin | ||
|
|
||
| import requests | ||
| from bs4 import BeautifulSoup | ||
|
|
||
| MYINSTANTS_URL = "https://www.myinstants.com" | ||
|
|
||
| HEADERS = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"} | ||
|
|
||
|
|
||
| def myinstants_get_random_sound(query: str | None, proxy: str | None) -> str | None: | ||
| if not query: | ||
| search_url = f"{MYINSTANTS_URL}/en/index/us/" | ||
| else: | ||
| search_url = f"{MYINSTANTS_URL}/en/search/" | ||
|
|
||
| proxies = None | ||
| if proxy: | ||
| proxies = { | ||
| "http": proxy, | ||
| "https": proxy, | ||
| } | ||
|
|
||
| try: | ||
| r = requests.get( | ||
| search_url, headers=HEADERS, params={"name": query} if query else None, timeout=10, proxies=proxies | ||
| ) | ||
| except requests.RequestException: | ||
| return None | ||
|
|
||
| if r.status_code != 200: | ||
| return None | ||
|
|
||
| soup = BeautifulSoup(r.text, "html.parser") | ||
|
|
||
| buttons = soup.find_all("button", onclick=True) | ||
| mp3_paths = [] | ||
|
|
||
| for btn in buttons: | ||
| onclick_value = btn["onclick"] | ||
| if "play(" in onclick_value: | ||
| match = re.search(r"play\('(.+?\.mp3)'", onclick_value) | ||
| if match: | ||
| mp3_paths.append(match.group(1)) | ||
|
|
||
| if not mp3_paths: | ||
| return None | ||
|
|
||
| mp3_url = urljoin(MYINSTANTS_URL, secrets.choice(mp3_paths)) | ||
| return mp3_url | ||
|
Dolly132 marked this conversation as resolved.
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = "1.4.0" | ||
| __version__ = "1.5.0" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.