Skip to content

Commit 746c000

Browse files
try 25
1 parent 03b5bd4 commit 746c000

31 files changed

+43
-8
lines changed

25.py

+38-7
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,57 @@
11
import requests
2+
import wave
23

34

45
def main():
56
seed = "http://www.pythonchallenge.com/pc/hex/"
67
file_path = "lake/"
7-
first_step(seed, file_path)
8+
auth = ("butter", "fly")
9+
# first_step(seed, file_path, auth)
10+
bs = second_step()
11+
third_step(bs)
812

913

10-
def first_step(seed, file_path):
11-
for i in range(2, 26):
12-
url = seed + str(i) + ".wav"
14+
def first_step(seed, file_path, auth):
15+
for i in range(1, 26):
16+
url = seed + "lake" + str(i) + ".wav"
1317
file_name = file_path + str(i) + ".wav"
14-
download_a_file(url, file_name)
18+
download_a_file(url, file_name, auth)
1519

1620

17-
def download_a_file(url, file_name):
18-
res = requests.get(url)
21+
def download_a_file(url, file_name, auth):
22+
res = requests.get(url, auth=auth)
1923
bs = res.content
2024
file = open(file_name, "wb")
2125
file.write(bs)
2226
print("Download {}".format(file_name))
2327

2428

29+
def second_step():
30+
bsAry = []
31+
for i in range(1, 26):
32+
lake = wave.open("lake/{}.wav".format(i), "rb")
33+
bs = lake.readframes(lake.getnframes())
34+
print(bs)
35+
bsAry.append(bs)
36+
lake.close()
37+
return bsAry
38+
39+
40+
def third_step(bs):
41+
result_file = wave.open("lake/result.wav", "wb")
42+
src_file = wave.open("lake/1.wav", "rb")
43+
nframes = src_file.getnframes()
44+
result_file.setnchannels(src_file.getnchannels())
45+
result_file.setsampwidth(src_file.getsampwidth())
46+
result_file.setframerate(src_file.getframerate())
47+
result_file.setnframes(nframes * 25)
48+
for i in range(len(bs)):
49+
b = bs[i]
50+
result_file.writeframesraw(b)
51+
src_file.close()
52+
result_file.close()
53+
print("Done")
54+
55+
2556
if __name__ == "__main__":
2657
main()

lake/1.wav

10.6 KB
Binary file not shown.

lake/10.wav

10.2 KB
Binary file not shown.

lake/11.wav

10.2 KB
Binary file not shown.

lake/12.wav

10.2 KB
Binary file not shown.

lake/13.wav

10.2 KB
Binary file not shown.

lake/14.wav

10.2 KB
Binary file not shown.

lake/15.wav

10.2 KB
Binary file not shown.

lake/16.wav

10.2 KB
Binary file not shown.

lake/17.wav

10.2 KB
Binary file not shown.

lake/18.wav

10.2 KB
Binary file not shown.

lake/19.wav

10.2 KB
Binary file not shown.

lake/2.wav

10.2 KB
Binary file not shown.

lake/20.wav

10.2 KB
Binary file not shown.

lake/21.wav

10.2 KB
Binary file not shown.

lake/22.wav

10.2 KB
Binary file not shown.

lake/23.wav

10.2 KB
Binary file not shown.

lake/24.wav

10.2 KB
Binary file not shown.

lake/25.wav

10.2 KB
Binary file not shown.

lake/3.wav

10.2 KB
Binary file not shown.

lake/4.wav

10.2 KB
Binary file not shown.

lake/5.wav

10.2 KB
Binary file not shown.

lake/6.wav

10.2 KB
Binary file not shown.

lake/7.wav

10.2 KB
Binary file not shown.

lake/8.wav

10.2 KB
Binary file not shown.

lake/9.wav

10.2 KB
Binary file not shown.

lake/result.wav

264 KB
Binary file not shown.

maze/maze/maze.jpg

19.2 KB
Loading

maze/maze/mybroken.gif

2.74 KB
Loading

maze/maze/mybroken.zip

2.64 KB
Binary file not shown.

read-bin-file.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ def read_bin_file(file_path):
1313
if __name__ == "__main__":
1414
# read_bin_file("copper/white.gif")
1515
# read_bin_file("channel/channel.zip")
16-
read_bin_file("maze/maze.zip")
16+
# read_bin_file("maze/maze.zip")
17+
# read_bin_file("lake/2.wav")
18+
# read_bin_file("indian/indian.wav")
19+
# read_bin_file("indian/result.wav")
20+
read_bin_file("maze/maze/mybroken.gif")

0 commit comments

Comments
 (0)