-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.py
178 lines (171 loc) · 5.94 KB
/
console.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import os
import time
from importlib import import_module
from scraping.common import write_csv
from scraping.common import fill_index
from scraping.common import create_index
from scraping.common import download_html
from scraping.common import download_audio
SERVICES = {
'soundfxcenter': [
dict(name='starcraft',
category='Video Games',
section='StarCraft',
more='SC',
url_path='/sound-effects/starcraft/'),
dict(name='warcraft2',
category='Video Games',
section='Warcraft 2',
more='WC Warcraft2',
url_path='/sound-effects/warcraft-2/'),
dict(name='terminator',
category='Movies',
section='Terminator',
url_path='/sound-effects/terminator/'),
dict(name='300',
category='Movies',
section='300',
url_path='/sound-effects/300/'),
dict(name='backtothefuture',
category='Movies',
section='Back to the Future',
url_path='/sound-effects/back-to-the-future/'),
dict(name='batman',
category='Movies',
section='Batman',
url_path='/sound-effects/batman/'),
dict(name='despicableme',
category='Movies',
section='Despicable Me',
url_path='/sound-effects/despicable-me/'),
dict(name='forrestgump',
category='Movies',
section='Forrest Gump',
url_path='/sound-effects/forrest-gump/'),
dict(name='harrypotter',
category='Movies',
section='Harry Potter',
url_path='/sound-effects/harry-potter/'),
dict(name='matrix',
category='Movies',
section='Matrix',
url_path='/sound-effects/matrix/'),
dict(name='starwars',
category='Movies',
section='Star Wars',
url_path='/sound-effects/star-wars/'),
dict(name='lotr',
category='Movies',
section='The Lord of the Rings',
more='LotR',
url_path='/sound-effects/the-lord-of-the-rings/'),
dict(name='toystory',
category='Movies',
section='Toy Story',
url_path='/sound-effects/toy-story/'),
dict(name='walle',
category='Movies',
section='Wall-E',
more='WallE',
url_path='/sound-effects/wall-e/'),
dict(name='supermario',
category='Video Games',
section='Super Mario Bros',
url_path='/sound-effects/super-mario-bros/'),
dict(name='futurama',
category='TV Series',
section='Futurama',
url_path='/sound-effects/futurama/'),
dict(name='simpsons',
category='TV Series',
section='The Simpsons',
url_path='/sound-effects/the-simpsons/'),
dict(name='bigbang',
category='TV Series',
section='The Big Bang Theory',
more='BBT',
url_path='/sound-effects/the-big-bang-theory/'),
dict(name='southpark',
category='TV Series',
section='South Park',
url_path='/sound-effects/south-park/'),
dict(name='tarzan',
category='Movies',
section='Tarzan',
url_path='/sound-effects/tarzan/'),
dict(name='startrek',
category='TV Series',
section='Star Trek',
url_path='/sound-effects/star-trek/'),
dict(name='spongebob',
category='TV Series',
section='Spongebob',
url_path='/sound-effects/spongebob-squarepants/'),
dict(name='flintstones',
category='TV Series',
section='The Flintstones',
url_path='/sound-effects/the-flintstones/'),
dict(name='looneytunes',
category='TV Series',
section='Looney Tunes',
url_path='/sound-effects/looney-tunes/'),
dict(name='familyguy',
category='TV Series',
section='Family Guy',
url_path='/sound-effects/family-guy/'),
dict(name='disney',
category='Movies',
section='Disney',
url_path='/sound-effects/disney/'),
],
'dota2gamepedia': [
dict(name='heroes',
category='Video Games',
section='Dota 2',
more='Dota2',
url_path='/Hero_Grid'),
],
'springfieldfiles': [
dict(name='sounds',
category='TV Series',
section='The Simpsons',
url_path='index.php?jump=sounds'),
],
'instantsfun': [
dict(name='sounds',
url_path='/'),
],
# 'myinstants': [
# dict(name='sounds',
# url_path='/'),
# ],
}
def process(service, section, html=False, csv=False, fill=False, audio=False):
# Paths
output_path = os.path.join('data', service+'_'+section['name'])
html_dir = os.path.join(output_path, 'html')
audio_dir = os.path.join(output_path, 'audio')
csv_path = os.path.join(output_path, 'audio.csv')
# Module import
module = import_module('scraping.%s' % service)
# Download
if html:
download_html(module.pages, section['url_path'], html_dir)
if csv:
write_csv(module.sounds, html_dir, csv_path,
section.get('category', ''),
section.get('section', ''),
section.get('more', ''))
if fill:
fill_index('indexdir', csv_path)
if audio:
download_audio(csv_path, audio_dir)
if __name__ == '__main__':
t0 = time.time()
create_index('indexdir')
for service, sections in SERVICES.items():
for section in sections:
process(service, section,
html=False, csv=False, fill=False, audio=False)
t1 = time.time()
print(t1 - t0)