· 4 years ago · Jul 07, 2021, 10:18 AM
1"""
2skript Author: tmm88
3jaar: 2021/7/6
4
5language: python
6
7tools used:
8* os sys json re python3 python2 pip3 pip2
9* wikipedia
10
11description (abstrakt):
12* performs a search in wikipedia throughout wikipedia api
13* retrieves a dictionary with the search results
14* opens the tags in different websites
15* provides a small script for downloading videos from youtube
16* runs a wget on the relevant search query and retrieves to the program
17"""
18
19### ****************************************************** ###
20
21# IMPORT CORE LIBRARIES
22import os
23import sys
24import json
25import re
26
27### ****************************************************** ###
28
29# INSTALL SOME RUBBISH
30
31"""
32os.system("sudo pacman -S python python3 python2")
33os.system("sudo pacman -S python2-pip python3-pip python-pip")
34os.system("sudo pacman -S youtube-dl ffmpeg")
35
36### ********************************************************* ###
37
38os.system("sudo pip3 install wikipedia")
39os.system("sudo pip2 install wikipedia")
40os.system("sudo pip2 install pytube")
41os.system("sudo pip2 install youtube-search-python")
42"""
43
44### ********************************************************* ###
45
46# import extra libraries
47import wikipedia
48from pytube import YouTube
49from youtubesearchpython import VideosSearch
50
51### ********************************************************* ###
52
53# reading argumenten
54wikipediaSearchTag = sys.argv[1]
55
56search=wikipedia.search(str(wikipediaSearchTag))
57
58### ********************************************************* ###
59
60#iterating dict in wikipedia
61
62myKey=str('test')
63
64for key in search:
65 url = key
66 mURL=url.replace(" ", "+").lower().replace(".", "")
67 print(mURL)
68
69 os.system("xdg-open https://www.zoek.nl/?q="+mURL)
70 os.system("xdg-open https://fireball.com/search?q="+mURL)
71 os.system("xdg-open https://www.reddit.com/search?q="+mURL)
72 os.system("xdg-open https://soundcloud.com/"+mURL)
73 os.system("xdg-open https://stackoverflow.com/search?q="+mURL)
74 os.system("xdg-open https://en.wikipedia.org/wiki/"+mURL)
75 os.system("xdg-open https://www.zoek.nl/?q="+mURL)
76 os.system("xdg-open https://www.youtube.com/results?search_query="+mURL)
77
78 ### RETRIEVE PAGES IN SEARCH FOR DOWNLOAD
79 """
80 os.system("wget -m https://www.zoek.nl/?q="+mURL)
81 os.system("wget -m https://fireball.com/search?q="+mURL)
82 os.system("wget -m https://www.reddit.com/search?q="+mURL)
83 os.system("wget -m https://soundcloud.com/"+mURL)
84 os.system("wget -m https://stackoverflow.com/search?q="+mURL)
85 os.system("wget -m https://en.wikipedia.org/wiki/"+mURL)
86 os.system("wget -m https://www.zoek.nl/?q="+mURL)
87 os.system("wget -m https://www.youtube.com/results?search_query="+mURL)
88 """
89
90 search_result=VideosSearch(mURL, limit=2).result()
91
92 # Aah it retuned a dict. No json!! json is just a data-interchange format!
93 print('search result type:', type(search_result))
94
95 ### ********************************************************* ###
96
97 ### ITERATES THROUGHOUT DAS UBBER FANTASTICHEN UBBER SKRIPT IN DAS UN IKONIKEN UBBER SCHNELL MIT MEIN FLAMMEN ARGANEL
98 if 'result' in search_result: # safety check in case there's no result.
99 for result_entry in search_result['result']: # I asume the result is always a list
100 url = result_entry['link']
101 ###os.system("cd /home/tmm88; youtube-dl " + url)
102
103 stream = YouTube(url).streams.first()
104 print('download from youtube url' , url, 'size in bytes', stream.filesize)
105
106 stream.download('/home/tmm88/') # Change this.
107 print('download ready')
108
109
110### ********************************************************* ###
111