Skip to content

Commit 18098ae

Browse files
committed
Work on translations
1 parent b190ed5 commit 18098ae

2 files changed

Lines changed: 115 additions & 4 deletions

File tree

srt/download_en.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
# https://pypi.org/project/python-youtube/
33

44
import math
5+
import json
6+
import hashlib
57
from youtube_transcript_api import YouTubeTranscriptApi
68
from pyyoutube import Api
79
from secret import api_key
810

9-
api = Api(api_key=api_key());
11+
api = Api(api_key=api_key())
12+
language = 'en'
1013

1114
# 1.89 -> 00:00:01,890
1215
def time2str(ticks) :
13-
frac = int( ticks * 1000 ) % 1000;
16+
frac = int( ticks * 1000 ) % 1000
1417
ticks = int(math.floor(ticks))
1518
hh = int(math.floor(ticks / (60*60)))
1619
ticks = ticks - (hh*60*60)
@@ -21,21 +24,29 @@ def time2str(ticks) :
2124

2225
playlist_item_by_playlist = api.get_playlist_items(playlist_id="PLlRFEj9H3Oj7Bp8-DfGpfAfDBiblRfl5p", count=None)
2326

27+
chksum = dict()
28+
2429
for item in playlist_item_by_playlist.items :
2530
title = item.snippet.title
2631
videoId = item.snippet.resourceId.videoId
2732
print(videoId, title)
28-
filename = 'en/' + title.replace('/','-') + ' - ' + videoId + '.srt'
29-
print(filename)
3033

3134
try:
3235
captions = YouTubeTranscriptApi.get_transcript(videoId)
3336
except:
3437
continue
3538

39+
jsonstr = json.dumps(captions)
40+
md = hashlib.md5(jsonstr.encode()).hexdigest()
41+
42+
3643
# {'text': 'Hello everybody and welcome to chapter', 'start': 0.0, 'duration': 1.89}
3744
# {'text': "one of Python for Everybody. I'm Charles", 'start': 1.89, 'duration': 1.92}
3845

46+
filename = language + '/' + title.replace('/','-') + ' - ' + videoId + '.srt'
47+
print(filename, md)
48+
chksum[filename] = md
49+
3950
with open(filename, "w") as f:
4051
for i in range(len(captions)):
4152
caption = captions[i]
@@ -62,3 +73,8 @@ def time2str(ticks) :
6273
# 00:00:01,890 --> 00:00:03,810
6374
# one of Python for Everybody. I'm Charles
6475

76+
checkfile = language + '/_index.json'
77+
chk = json.dumps(chksum, indent=4)
78+
text_file = open(checkfile, "w")
79+
n = text_file.write(chk)
80+
text_file.close()

srt/en/_index.json

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"en/Python for Everybody - The most popular programming course in the world - UjeNA_JtXME.srt": "442c118ad3d8c10c648888e7b843b9d0",
3+
"en/PY4E - Introduction (Chapter 1 Part 1) - fvhNadKjE8g.srt": "463ceaa814b9e4b720376edf62c13699",
4+
"en/PY4E - Introduction (Chapter 1 Part 2) - VQZTZsXk8sA.srt": "d6affb965d6bb4a463dba0c81737a9a7",
5+
"en/PY4E - Introduction (Chapter 1 Part 3) - LLzFNlCjTSo.srt": "43a785c88738b19aefbd444f23309d29",
6+
"en/PY4E - Introduction (Chapter 1 Part 4) - gsry2SYOFCw.srt": "a4f96248f6cf4675e2a224be06c52d7a",
7+
"en/Welcome to Python Programming - fp17_21c9lU.srt": "1118edc3a1d75f170fd2665eee4e9ca8",
8+
"en/Installing Python 3 on Windows-10 - uZbaYeYGYRQ.srt": "4afa2e144684a3572fada3f417ce4890",
9+
"en/Installing a Python 3 on a Macintosh - aIcLCww_kQM.srt": "5aafbd9591f277aec685a6f83cccc4d6",
10+
"en/Worked Exercise - Hello World - aDwb41EMEQQ.srt": "769a4c334bf1578976af5fc6efef30b3",
11+
"en/PY4E - Introduction (Chapter 2 Part 1) - 7KHdV6FSpo8.srt": "2b1065c9c03c0f8b954087b528ed2b8b",
12+
"en/PY4E - Introduction (Chapter 2 Part 2) - kefrGMAglGs.srt": "9d28ce14606fc0e8916d4c647b5221ee",
13+
"en/Worked Exercise 2.2 - _b-nVJrl02M.srt": "edff854832228355ac7b087e333c923e",
14+
"en/Worked Exercise 2.3 - DVmspDooG2c.srt": "42e0142bad478d2517e97b2661006afb",
15+
"en/PY4E - Conditionals (Chapter 3 Part 1) - 2aA3VBdcl6A.srt": "255c5b55a43db92b9dc5d37dc3f14916",
16+
"en/PY4E - Conditionals (Chapter 3 Part 2) - OczkNrHPBps.srt": "13d268c3d51dfa6893181627cf77eeec",
17+
"en/Worked Exercise 3.1 - oUMQbZ4SBuM.srt": "17949208ab3a73554ab1877e5e5697ac",
18+
"en/Worked Exercise 3.2 - -iUA4cCKRlM.srt": "2625c807602022fec27e551bc596b398",
19+
"en/PY4E - Functions (Chapter 4 Part 1) - 5Kzw-0-DQAk.srt": "35f116c98019dbf3ab516d3edb94df13",
20+
"en/PY4E - Functions (Chapter 4 Part 2) - AJVNYRqn8kM.srt": "14e899ca3edb4daf1917037f2a0b86a9",
21+
"en/Worked Exercise 4.6 - l93PhBUJ_S0.srt": "17b456d8dfe628f47a834c4fd8133502",
22+
"en/PY4E - Loops and Iteration (Chapter 5 Part 1) - FzpurxjwmsM.srt": "aef279cad5c48e58d25d7caf6e0101dd",
23+
"en/PY4E - Loops and Iteration (Chapter 5 Part 2) - 5QDrj5ogPYc.srt": "8802c901a09f654ac91c5b899f0f7a1d",
24+
"en/PY4E - Loops and Iteration (Chapter 5 Part 3) - xsavQp8hd78.srt": "213f8b5159a491a798bca79036ea1857",
25+
"en/PY4E - Loops and Iteration (Chapter 5 Part 4) - yjlMMwf9Y5I.srt": "dbed12a6e680e16b97c9b2160aa505c9",
26+
"en/Worked Exercise 5.1 - R2GrfqRofZc.srt": "c07e56f5c3383c564a0ca16643a28f9c",
27+
"en/PY4E - Strings (Chapter 6 Part 1) - dr98iM4app8.srt": "5f2c0669cf53bc55572c8bb3a57cd700",
28+
"en/PY4E - Strings (Chapter 6 Part 2) - bIFpJ-qZ3Cc.srt": "67501309cfc83ece076239749d4786ec",
29+
"en/Worked Exercise 6.5 - BGTxwsDI9KY.srt": "f981abfc59eb6c48ce6045a6583e5114",
30+
"en/PY4E - Files (Chapter 7 Part 1) - 9KJ-XeQ6ZlI.srt": "ef3a2d8a30997c43657aed0fb7abf900",
31+
"en/PY4E - Files (Chapter 7 Part 2) - 0t4rvnySKR4.srt": "10efd1b683b4e5d5021fbb1009d0f0c5",
32+
"en/Worked Exercise 7.1 - Opening and Reading a File - MHZ4KnFZ7Y0.srt": "9eb9c0b1648c30b9ac9df91bbdb93204",
33+
"en/PY4E - Python Lists (Chapter 8 Part 1) - ljExWqnWQvo.srt": "6a312248cbd2e99f18ba3a4bb992141a",
34+
"en/PY4E - Python Lists (Chapter 8 Part 2) - bV1FQUBIApM.srt": "b3c630f2ef38336ce3e6b9ac9bd59aee",
35+
"en/PY4E - Python Lists (Chapter 8 Part 3) - GxADdpo6EP4.srt": "73a7b1c6fb5097e47c6498b045854df6",
36+
"en/Strings, Files, Lists and the Guardian Pattern (Chapter 8) - WU6_0A9zYRA.srt": "f8e9c87a6af814c166210d5dd041da56",
37+
"en/PY4E - Dictionaries (Chapter 9 Part 1) - yDDRMb-1cxI.srt": "00d80107cfd484e84ecbdabf498420a8",
38+
"en/PY4E - Dictionaries (Chapter 9 Part 2) - LRSIuH94XM4.srt": "c8eb23e0e932dd1713e8b2d6569d9a4a",
39+
"en/PY4E - Dictionaries (Chapter 9 Part 3) - ZDjiFB1Ib84.srt": "82aa06737b53178e183d82c47e845c3f",
40+
"en/Counting Word Frequency using a Dictionary (Chapter 9) - lLbyEYjU55A.srt": "dcac59bd90c4c21caefa2554433a288a",
41+
"en/PY4E - Tuples (Chapter 10 Part 1) - CaVhM65wD6g.srt": "1048b362199ea8ff94b131abd9e2ee33",
42+
"en/PY4E - Tuples (Chapter 10 Part 2) - FdUdA6o0Ij0.srt": "0f5d143ecc8b112aae71aeb95bf3528a",
43+
"en/Sorting a Dictionary using Tuples (Chapter 10) - hMJpet-gtc0.srt": "2b2a18e9652c943ed58cf6ac142c885c",
44+
"en/PY4E - Regular Expressions (Chapter 11 Part 1) - ovZsvN67Glc.srt": "afa110de0867d4f2b56443aedd0b04bb",
45+
"en/PY4E - Regular Expressions (Chapter 11 Part 2) - fiar4QZZ7Xo.srt": "055f62b3051b76bee2ad17cbf5080c33",
46+
"en/PY4E - Regular Expressions (Chapter 11 Part 3) - GiQdXo2Bvgc.srt": "62900c83b39257e241428908b703c9b5",
47+
"en/PY4E - HTTP (Chapter 12 Part 1) - RsnaRPC52G0.srt": "9de24c02d0f854e0f3e81482677a2250",
48+
"en/PY4E - HTTP (Chapter 12 Part 2) - Bvx7vY454xw.srt": "2a46fa51023248f5adc2ab73c1da4b33",
49+
"en/PY4E - HTTP (Chapter 12 Part 3) - Lr9Vm-VghAk.srt": "aa3c5d011c952a0a8c02ad59bb7e9412",
50+
"en/Worked Example: Sockets (Chapter 12) - EqUyu8ZZYUE.srt": "3288e9f85bb1967d29453a45b244f4ad",
51+
"en/PY4E - Unicode and UTF-8 in Python (Chapter 12 Part 4) - -cmlmaVSONg.srt": "b12b4596d38f8204d26a779534c857dd",
52+
"en/PY4E - HTTP (Chapter 12 Part 5) - k1sUxGPpQOk.srt": "b39cba2742181d4247d8820c23edcb39",
53+
"en/Worked Example: Using Urllib (Chapter 12) - jKaCKIdIoks.srt": "a544d7d0feff896962b2b017afc36420",
54+
"en/PY4E - HTTP (Chapter 12 Part 6) - D7ZI8--qbBw.srt": "3f18bdc197b8247b8d0b226387dce4ac",
55+
"en/Worked Example: BeautifulSoup (Chapter 12) - mhaHWiSPxxE.srt": "fc49cc77574775019cf8a0626660ce87",
56+
"en/PY4E - Web Services (Chapter 13 Part 1) - 7NEtEctD9Cw.srt": "60efa3879fee4ffeb67b0fcdb89f0142",
57+
"en/PY4E - Web Services - XML (Chapter 13 Part 2) - A8KcBx9153Y.srt": "55e78b603e796838607572f6c73a0fc1",
58+
"en/Worked Example: XML (Chapter 13) - 7q8uUehNRK0.srt": "36e1995aa1bcdfff874a795293ae9743",
59+
"en/PY4E - Web Services - XML Schema (Chapter 13 Part 3) - 0cA6W-4JPQ4.srt": "36e64be187d046f96b95dae392dadfb7",
60+
"en/PY4E - Web Services - JSON (Chapter 13 Part 4) - J5DjteDzgoM.srt": "1f48a98c6ee4a99049d2500c8653fcd7",
61+
"en/Worked Example: JSON (Chapter 13) - RGQfDirZ7_s.srt": "a5ea508456d5cf163323faaf7bf26bcb",
62+
"en/Discovering JavaScript Object Notation with Douglas Crockford - kc8BAR7SHJI.srt": "8644e04b82ec344ab310fd60514496f4",
63+
"en/PY4E - Web Services - SOA (Chapter 13 Part 5) - SNeJcvBY-h4.srt": "04f32734f05045a5847dd83aff64a889",
64+
"en/JISC e-Framework - mj-kCFzF0ME.srt": "b529eda409a6dbdc41e1a29276778ca5",
65+
"en/PY4E - Web Services - GeoJSON (Chapter 13 Part 6) - QyHcOL3C7fQ.srt": "d87a49f133e98e1cd932fd0b9e0b81c7",
66+
"en/Worked Example: GeoJSON API (Chapter 13) - vjQZscHOaG4.srt": "d60b2a6a0e39e111fcd05690e14fcc33",
67+
"en/PY4E - Web Services - Twitter (Chapter 13 Part 7) - mrRo2xX39nw.srt": "424c6f125c76d614fb416de7856b5cf1",
68+
"en/Worked Example: Twitter API (Chapter 13) - zJzPyEPCbXs.srt": "5d1d750add212ab790a53867f9316057",
69+
"en/PY4E - Python Objects (Chapter 14 Part 1) - u9xZE5t9Y30.srt": "6262ef0b6addf973a7a9abe24976b974",
70+
"en/PY4E - Python Objects (Chapter 14 Part 2) - b2vc5uzUfoE.srt": "7056738926beac01c8c9ee4b05723bdb",
71+
"en/PY4E - Python Objects (Chapter 14 Part 3) - bal0Fv6QE9w.srt": "f8e2ad0e55e2ca6c01f3bf1e873fc658",
72+
"en/PY4E - Python Objects (Chapter 14 Part 4) - EE9PaHPPm2w.srt": "d36783a56c6839dbfd2ec9c0d67386ad",
73+
"en/PY4E - Databases (Chapter 15 Part 1) - 3RMPveOMd0k.srt": "4a9da457d38b517740aaccd961e31afa",
74+
"en/PY4E - Databases - Single Table SQL (Chapter 15 Part 2) - yRJE-nk20sM.srt": "bd01f1752b9333372a399001caee06f0",
75+
"en/Worked Example: Emaildb.py (Chapter 15) - MsZoGw4QEpU.srt": "a54fc20a108a4dff75c63e3c79c1441f",
76+
"en/Worked Example: Twspider.py (Chapter 15) - wQNjza1gb_g.srt": "0643434a894816439e9fef935b14a951",
77+
"en/PY4E - Database - Complex Models (Chapter 15 Part 3) - rHjRpYUl5eg.srt": "a2ae84c057e228a7caf99e0b81dacf24",
78+
"en/PY4E - Databases (Chapter 15 Part 4) - PgE--P-ZWvU.srt": "ef6d9960851e8cee5822ff328084e249",
79+
"en/PY4E - Databases - Foreign Keys (Chapter 15 Part 5) - GfuH_8uH16k.srt": "73a4671158338dd0faacad2cda8c21ba",
80+
"en/PY4E - Databases - JOIN (Chapter 15 Part 6) - zMOSVrb82iU.srt": "18fc7e8ded04445fb6f24ab64f15450c",
81+
"en/Worked Example: Tracks.py (Chapter 15) - UGe7X_L-lHc.srt": "534da44d403ef4a86f6786e9176d5533",
82+
"en/PY4E - Databases - Many-to-Many (Chapter 15 Part 7) - uq_Wf4nuXqE.srt": "4c9d9807b056914467886ab43f236c7a",
83+
"en/Worked Example: Twfriends.py (Chapter 15) - A_TpMJkSOcI.srt": "dd79d9653da7de53e249550c717172b4",
84+
"en/PY4E - Visualization (Chapter 16 Part 1) - gy6l4DTv1KU.srt": "ca9f9b3b6ce33da3f8a3d49430ad8dbf",
85+
"en/Worked Example: Geodata (Chapter 16) - mt03Z2QjndQ.srt": "7f18abff5dd61ce74a3a04bf0ca71b58",
86+
"en/PY4E - Visualization (Chapter 16 Part 2) - x2KMFkvDtI8.srt": "51142f338573e09e02a52c202885a6ec",
87+
"en/Worked Example: Page Rank - Spidering (Chapter 16) - SbtGozLk5Yk.srt": "e3d926a64d87e12f79f9d67466bb42d7",
88+
"en/Worked Example: Page Rank - Computation (Chapter 16) - 9gtLOS87ZPs.srt": "9c31472c838955e5945cf8e7eb504dbc",
89+
"en/Worked Example: Page Rank - Visualization (Chapter 16) - vM4kJNePwhI.srt": "e4b39e132bc2847be071afd7876bccd7",
90+
"en/PY4E - Visualization (Chapter 16 Part 3) - vE0_PM2BOiU.srt": "7d613b683c33977356ff6386ba2cfb65",
91+
"en/Worked Example: Gmane - Mail - Retrieval (Chapter 16) - NFS5MLKdNGw.srt": "9ecac8496f29a875815c4cf3e71ab22a",
92+
"en/Worked Example: Gmane - Mail - Model (Chapter 16) - 8GHtT7GqRKk.srt": "eedac9fe0dffaedb115289dcfd29e646",
93+
"en/Worked Example: Gmane - Mail - Visualization (Chapter 16) - AQtKm02FQq4.srt": "c4c41d5a80cf4aaff430ff8148d71e69",
94+
"en/MOOC Graduation Video with Curt Bonk as Commencement Speaker - SfQYA0JQWkA.srt": "964f82db4bccd00d66bfe7adc00a4d12"
95+
}

0 commit comments

Comments
 (0)