· 4 years ago · Jul 07, 2021, 04:40 PM
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
18currently site saving doesn't works but with limitations
19"""
20
21### ****************************************************** ###
22
23# IMPORT CORE LIBRARIES
24import os
25import sys
26import json
27import re
28
29### ****************************************************** ###
30
31# INSTALL SOME RUBBISH
32
33"""
34os.system("sudo pacman -S python python3 python2")
35os.system("sudo pacman -S python2-pip python3-pip python-pip")
36os.system("sudo pacman -S youtube-dl ffmpeg")
37
38### ********************************************************* ###
39
40os.system("sudo pip3 install wikipedia")
41os.system("sudo pip2 install wikipedia")
42os.system("sudo pip2 install pytube")
43os.system("sudo pip2 install youtube-search-python")
44os.system("sudo pip install pywebcopy")
45os.system("sudo pip2 install pywebcopy")
46os.system("sudo pip3 install pywebcopy")
47os.system("pip install googlesearch-python")
48"""
49
50### ********************************************************* ###
51
52### //////////////////////// ###
53
54# import extra libraries
55import wikipedia
56
57### //////////////////////// ###
58
59from pytube import YouTube
60from youtubesearchpython import VideosSearch
61
62### //////////////////////// ###
63
64from pywebcopy import save_webpage
65from googlesearch import search
66
67### //////////////////////// ###
68
69### ********************************************************* ###
70
71# reading argumenten
72wikipediaSearchTag = sys.argv[1]
73
74#search=wikipedia.search(str(wikipediaSearchTag))
75print(search)
76
77search2=search(str(wikipediaSearchTag))
78print(search2)
79
80for key in search2:
81 print(key)
82 kwargs = {'project_name': 'some-fancy-name'}
83 save_webpage(url=key, project_folder='/home/tmm88', **kwargs)
84
85### ********************************************************* ###
86
87#iterating dict in wikipedia
88
89myKey=str('test')
90
91for key in search:
92 url = key
93 mURL=url.replace(" ", "+").lower().replace(".", "")
94 print(mURL)
95
96 search2=search(str(key))
97 print(search2)
98
99 for key2 in search2:
100 print(key2)
101 kwargs = {'project_name': 'some-fancy-name'}
102 save_webpage(url=key2, project_folder='/home/tmm88', **kwargs)
103
104 search_result=VideosSearch(mURL, limit=10000).result()
105
106 # Aah it retuned a dict. No json!! json is just a data-interchange format!
107 print('search result type:', type(search_result))
108
109 ### ********************************************************* ###
110
111 ### ITERATES THROUGHOUT DAS UBBER FANTASTICHEN UBBER SKRIPT IN DAS UN IKONIKEN UBBER SCHNELL MIT MEIN FLAMMEN ARGANEL
112 if 'result' in search_result: # safety check in case there's no result.
113 for result_entry in search_result['result']: # I asume the result is always a list
114
115 url = result_entry['link']
116 ###os.system("cd /home/tmm88; youtube-dl " + url)
117
118 stream = YouTube(url).streams.first()
119 print('download from youtube url' , url, 'size in bytes', stream.filesize)
120
121 stream.download('/home/tmm88/') # Change this.
122 print('download ready')
123
124 print(result_entry['title'])
125 print(result_entry['link'])
126
127### ********************************************************* ###
128
129