- Spoiler: show
- Moin Zusammen,
gerne möchte ich mit euch ein Script Teilen welches ihr fix selber aufbauen könnt.
Umgang mit Python vorausgesetzt.
Dieses Script ist ein Webcrawler mit der Funktion Videos direkt von der Webseite abzuspielen.
Die Aufgerufen Webseite ist https://hypnotube.com/ Sissy Content
Vorwort:- Spoiler: show
- Was macht dieses Script:
1) Suche & Abspielen: Fordere nach einem Suchbegriff und spiele dann ein zufälliges Video ab. Die Suchliste wird dann gelöscht.
2) Suche & Speichern: Fragt nach einem Suchbegriff und speichert die Liste unter dem Namen der Suche (kein Video wird abgespielt).
3) Auswählen & Abspielen: Fordere eine Linkliste an (z.B. von Option 2) und spiele ein zufälliges Video daraus ab.
4) Marathon: Fragt nach einem Suchbegriff und spielt ein zufälliges Video ab, das dann von der Liste gelöscht wird. Du wirst dann gefragt, ob du fortfahren möchtest. Das Ganze kann wiederholt werden, bis die Liste leer ist.
5) Beenden: Sollte klar sein, oder?
- Spoiler: show
-
Denkt an die Abhängigkeiten (os, requests, bs4, random, webbrowser, urllib.parse) diese können mit pip nachinstalliert werden.
Script update: Suche konnte nur ein Wort erfassen. (Behoben)Code: Select all
import os import requests from bs4 import BeautifulSoup import random import webbrowser import urllib.parse def get_video_links(url, output_file): video_links = [] try: response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') for source_tag in soup.find_all('source', src=True): src = source_tag.get('src') if src.endswith('.mp4'): video_links.append(src) except Exception as e: print(f"Error fetching video links from {url}: {e}") return video_links def get_search_results(search_term): search_term_encoded = urllib.parse.quote_plus(search_term) main_url = f"https://hypnotube.com/search/{search_term_encoded}/page{{}}.html" all_links = [] try: for page_num in range(1, 21): page_url = main_url.format(page_num) response = requests.get(page_url) soup = BeautifulSoup(response.text, 'html.parser') for link in soup.find_all('a', href=True): href = link.get('href') if href.startswith('https://hypnotube.com/video/'): all_links.append(href) except Exception as e: print(f"Error fetching search results for {search_term}: {e}") return all_links def play_random_video(links): if links: random_link = random.choice(links) print(f"Playing random video: {random_link}") try: response = requests.get(random_link) soup = BeautifulSoup(response.text, 'html.parser') for source_tag in soup.find_all('source', src=True): src = source_tag.get('src') if src.endswith('.mp4'): print(f"Playing video: {src}") webbrowser.open(src) return print("No video found on the selected page.") except Exception as e: print(f"Error playing video from {random_link}: {e}") else: print("No video links found.") def save_search_results(search_term, links): filename = f"{search_term}.txt" with open(filename, "w") as f: for link in links: f.write(link + '\n') print(f"Search results have been saved to '{filename}'.") def select_and_play_video(): filename = input("Enter the name of the file containing video links: ") if not os.path.exists(filename): print("File not found.") return with open(filename, "r") as f: links = f.read().splitlines() play_random_video(links) def marathon_mode(): search_term = input("Enter search term: ") search_results = get_search_results(search_term) if search_results: filename = "marathon.txt" with open(filename, "w") as f: for link in search_results: f.write(link + '\n') print(f"Marathon list has been saved to '{filename}'.") while True: if not os.path.exists(filename): print("Marathon list file not found.") return with open(filename, "r") as f: links = f.read().splitlines() if links: random_link = random.choice(links) print(f"Playing random video: {random_link}") try: response = requests.get(random_link) soup = BeautifulSoup(response.text, 'html.parser') for source_tag in soup.find_all('source', src=True): src = source_tag.get('src') if src.endswith('.mp4'): print(f"Playing video: {src}") webbrowser.open(src) links.remove(random_link) with open(filename, "w") as f: for link in links: f.write(link + '\n') resume = input("Resume marathon? (y/n): ") if resume.lower() != "y": return break else: print("No video found on the selected page.") except Exception as e: print(f"Error playing video from {random_link}: {e}") else: print("No more videos left in the marathon list.") break else: print("No video links found for the search term.") def main(): while True: print("Select an option:") print("1) Search & Play") print("2) Search & Save") print("3) Select & Play") print("4) Marathon") print("5) Exit") option = input("Enter your choice: ") if option == "1": search_term = input("Enter search term: ") search_results = get_search_results(search_term) play_random_video(search_results) if os.path.exists("video_links.txt"): os.remove("video_links.txt") elif option == "2": search_term = input("Enter search term: ") search_results = get_search_results(search_term) save_search_results(search_term, search_results) elif option == "3": select_and_play_video() elif option == "4": marathon_mode() elif option == "5": print("Exiting the script.") break else: print("Invalid option.") if __name__ == "__main__": main()
- Spoiler: show
- Das Script ist so aufgebaut das es nach dem Filter "Most Relevant" schaut, wollt ihr das Ändern muss folgedende Zeile angepasst werden:
Most Relevant:
"Top Rating:Code: Select all
main_url = f"https://hypnotube.com/search/{search_term_encoded}/page{{}}.html"
Newest:Code: Select all
main_url = f"https://hypnotube.com/search/{search_term_encoded}/rating/page{{}}.html"
Most Viewed:Code: Select all
main_url = f"https://hypnotube.com/search/{search_term_encoded}/newest/page{{}}.html"
Code: Select all
main_url = f"https://hypnotube.com/search/{search_term_encoded}/views/page{{}}.html"
Viel Spaß
- Spoiler: show
- Hi everyone,
I'd like to share a script with you that you can easily set up yourself.
Python skills required.
This script is a web crawler that allows you to play videos directly from the website.
The website being accessed is https://hypnotube.com/ Sissy Content
Preface:- Spoiler: show
- What does this script do:
1) Search & Play Ask for a search term and then play a random video. The crawllist will then be deleted.
2) Search & Save Asks for a search term and saves the list with the name of the search (no video is played)
3) Select & Play Ask for a link list (e.g. from option 2) and play a random video from it.
4) Marathon Asks for a search term and plays a random video, which is then deleted from the list. You will then be asked if you want to continue. The whole thing can be repeated until the list is empty.
5) Exit should be clear right?
- Spoiler: show
-
Keep in mind the dependencies (os, requests, bs4, random, webbrowser, urllib.parse) which can be installed using pip.
Script update: Could only capture one word in the search term. (Fixed)Code: Select all
import os import requests from bs4 import BeautifulSoup import random import webbrowser import urllib.parse def get_video_links(url, output_file): video_links = [] try: response = requests.get(url) soup = BeautifulSoup(response.text, 'html.parser') for source_tag in soup.find_all('source', src=True): src = source_tag.get('src') if src.endswith('.mp4'): video_links.append(src) except Exception as e: print(f"Error fetching video links from {url}: {e}") return video_links def get_search_results(search_term): search_term_encoded = urllib.parse.quote_plus(search_term) main_url = f"https://hypnotube.com/search/{search_term_encoded}/page{{}}.html" all_links = [] try: for page_num in range(1, 21): page_url = main_url.format(page_num) response = requests.get(page_url) soup = BeautifulSoup(response.text, 'html.parser') for link in soup.find_all('a', href=True): href = link.get('href') if href.startswith('https://hypnotube.com/video/'): all_links.append(href) except Exception as e: print(f"Error fetching search results for {search_term}: {e}") return all_links def play_random_video(links): if links: random_link = random.choice(links) print(f"Playing random video: {random_link}") try: response = requests.get(random_link) soup = BeautifulSoup(response.text, 'html.parser') for source_tag in soup.find_all('source', src=True): src = source_tag.get('src') if src.endswith('.mp4'): print(f"Playing video: {src}") webbrowser.open(src) return print("No video found on the selected page.") except Exception as e: print(f"Error playing video from {random_link}: {e}") else: print("No video links found.") def save_search_results(search_term, links): filename = f"{search_term}.txt" with open(filename, "w") as f: for link in links: f.write(link + '\n') print(f"Search results have been saved to '{filename}'.") def select_and_play_video(): filename = input("Enter the name of the file containing video links: ") if not os.path.exists(filename): print("File not found.") return with open(filename, "r") as f: links = f.read().splitlines() play_random_video(links) def marathon_mode(): search_term = input("Enter search term: ") search_results = get_search_results(search_term) if search_results: filename = "marathon.txt" with open(filename, "w") as f: for link in search_results: f.write(link + '\n') print(f"Marathon list has been saved to '{filename}'.") while True: if not os.path.exists(filename): print("Marathon list file not found.") return with open(filename, "r") as f: links = f.read().splitlines() if links: random_link = random.choice(links) print(f"Playing random video: {random_link}") try: response = requests.get(random_link) soup = BeautifulSoup(response.text, 'html.parser') for source_tag in soup.find_all('source', src=True): src = source_tag.get('src') if src.endswith('.mp4'): print(f"Playing video: {src}") webbrowser.open(src) links.remove(random_link) with open(filename, "w") as f: for link in links: f.write(link + '\n') resume = input("Resume marathon? (y/n): ") if resume.lower() != "y": return break else: print("No video found on the selected page.") except Exception as e: print(f"Error playing video from {random_link}: {e}") else: print("No more videos left in the marathon list.") break else: print("No video links found for the search term.") def main(): while True: print("Select an option:") print("1) Search & Play") print("2) Search & Save") print("3) Select & Play") print("4) Marathon") print("5) Exit") option = input("Enter your choice: ") if option == "1": search_term = input("Enter search term: ") search_results = get_search_results(search_term) play_random_video(search_results) if os.path.exists("video_links.txt"): os.remove("video_links.txt") elif option == "2": search_term = input("Enter search term: ") search_results = get_search_results(search_term) save_search_results(search_term, search_results) elif option == "3": select_and_play_video() elif option == "4": marathon_mode() elif option == "5": print("Exiting the script.") break else: print("Invalid option.") if __name__ == "__main__": main()
- Spoiler: show
- The script is set up to look for "Most Relevant" filter, if you want to change it, the following line needs to be adjusted:
Most Relevant:Top Rating:Code: Select all
main_url = f"https://hypnotube.com/search/{search_term_encoded}/page{{}}.html"
Newest:Code: Select all
main_url = f"https://hypnotube.com/search/{search_term_encoded}/rating/page{{}}.html"
Most Viewed:Code: Select all
main_url = f"https://hypnotube.com/search/{search_term_encoded}/newest/page{{}}.html"
Code: Select all
main_url = f"https://hypnotube.com/search/{search_term_encoded}/views/page{{}}.html"
Enjoy!
- Spoiler: show
- Update Version 1.0.1
- Spoiler: show
- Script update: Could only capture one word in the search term. (Fixed)
- Spoiler: show
-
menu
There is now a menu in which you return after each action until you say exit or cancel the script.
The following options are now available
Select an option:
1) Search & Play Ask for a search term and then play a random video. The crawllist will then be deleted.
2) Search & Save Asks for a search term and saves the list with the name of the search (no video is played)
3) Select & Play Ask for a link list (e.g. from option 2) and play a random video from it.
4) Marathon Asks for a search term and plays a random video, which is then deleted from the list. You will then be asked if you want to continue. The whole thing can be repeated until the list is empty.
5) Exit should be clear right?