Skip to content

Commit 13c9b0a

Browse files
committed
优化字幕下载逻辑
1 parent 1af9462 commit 13c9b0a

22 files changed

+15515
-3090
lines changed

free-apps/Apple Event — May 7.chn.srt

Lines changed: 6678 additions & 1310 deletions
Large diffs are not rendered by default.

free-apps/Apple Event — May 7.eng.srt

Lines changed: 8210 additions & 1682 deletions
Large diffs are not rendered by default.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.coderdream.freeapps.util;
2+
3+
import com.google.gson.JsonObject;
4+
import com.google.gson.JsonParser;
5+
import org.apache.http.HttpEntity;
6+
import org.apache.http.HttpResponse;
7+
import org.apache.http.client.methods.HttpGet;
8+
import org.apache.http.impl.client.CloseableHttpClient;
9+
import org.apache.http.impl.client.HttpClients;
10+
import org.apache.http.util.EntityUtils;
11+
12+
import java.io.IOException;
13+
14+
public class NeteaseMusicApi {
15+
16+
private static final String API_URL = "https://api.imjad.cn/cloudmusic/?type=detail&id=";
17+
18+
public static void main(String[] args) {
19+
String songId = "32957955"; // 替换为实际的歌曲ID
20+
try {
21+
int favoritesCount = getFavoritesCount(songId);
22+
System.out.println("Favorites Count: " + favoritesCount);
23+
} catch (IOException e) {
24+
e.printStackTrace();
25+
}
26+
}
27+
28+
public static int getFavoritesCount(String songId) throws IOException {
29+
CloseableHttpClient httpClient = HttpClients.createDefault();
30+
HttpGet request = new HttpGet(API_URL + songId);
31+
32+
HttpResponse response = httpClient.execute(request);
33+
HttpEntity entity = response.getEntity();
34+
String result = EntityUtils.toString(entity);
35+
36+
JsonObject jsonObject = JsonParser.parseString(result).getAsJsonObject();
37+
JsonObject song = jsonObject.getAsJsonObject("songs").getAsJsonArray("data").get(0).getAsJsonObject();
38+
int favoritesCount = song.get("st").getAsInt();
39+
40+
httpClient.close();
41+
return favoritesCount;
42+
}
43+
}

free-apps/src/main/java/com/coderdream/freeapps/util/apple/event/GetSrtUtil.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616

1717
public class GetSrtUtil {
1818

19-
private final static String SRT_PRIO = "https://events-delivery.apple.com/2403kaqfcpzjjnpkkkkmbtyqacnyrknu/vod_main_BHKucdGHJBgbQdLdPafCRNCACvstwWNC/cc/";
19+
// private final static String SRT_PRIO = "https://events-delivery.apple.com/2403kaqfcpzjjnpkkkkmbtyqacnyrknu/vod_main_BHKucdGHJBgbQdLdPafCRNCACvstwWNC/cc/";
2020

21+
private final static String SRT_PRIO = "https://events-delivery.apple.com/1505clvgxdwlbjrjhxtjdgcdxaiabvuf/vod_main_BveVQvhWftXzpUakjHjEUkbmUYLbRdcV/cc/";
2122
private final static String END = ".webvtt";
2223
private final static String CN_PRIO = "zh/zh_";
2324
private final static String EN_PRIO = "en/en_";
@@ -29,20 +30,21 @@ public class GetSrtUtil {
2930
// zh/zh_0.webvtt
3031
public static void main(String[] args) {
3132

32-
Integer SIZE = 379;
33-
33+
// Integer SIZE = 379;
34+
Integer SIZE = 1025;
3435

36+
String urlBase = "https://events-delivery.apple.com/1505clvgxdwlbjrjhxtjdgcdxaiabvuf/vod_main_BveVQvhWftXzpUakjHjEUkbmUYLbRdcV/";
3537

3638

3739
List<String> urlCnList = new ArrayList<>();
3840
List<String> urlEnList = new ArrayList<>();
3941
for (int i = 0; i < SIZE; i++) {
40-
// System.out.println(SRT_PRIO + CN_PRIO + i + END);
42+
System.out.println(SRT_PRIO + CN_PRIO + i + END);
4143
urlCnList.add(SRT_PRIO + CN_PRIO + i + END);
4244
}
4345

4446
for (int i = 0; i < SIZE; i++) {
45-
// System.out.println(SRT_PRIO + EN_PRIO + i + END);
47+
System.out.println(SRT_PRIO + EN_PRIO + i + END);
4648
urlEnList.add(SRT_PRIO + EN_PRIO + i + END);
4749
}
4850
// m1();

free-apps/src/main/java/com/coderdream/freeapps/util/bbc/GenSixMinutePptx.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public static void main(String[] args) {
3535
/**
3636
* 分多步生成ppt
3737
*
38-
* @param folderName
39-
* @param titleName
38+
* @param folderName 文件夹名称
39+
* @param titleName 标题名称
4040
*/
4141
public static void genPpt(String folderName, String titleName) {
4242
// 第一步:设置标题图片

free-apps/src/main/java/com/coderdream/freeapps/util/bbc/TranslateUtil.java

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ public static void main(String[] args) {
2323
String folderName = "210318";
2424
// TranslateUtil.process(folderName);
2525
// TranslateUtil.mergeScriptContent(folderName);
26-
TranslateUtil.translateEngSrc(folderName);
26+
// TranslateUtil.translateEngSrc(folderName);
27+
28+
2729

2830
// String str = "大括号外面的内容(Michael Collins)的内容(Michael Collins) ";
2931
// str = removeEnContent(str);
3032
// System.out.println(str);
3133
//
32-
// List<String> NUMBER_LIST = Arrays.asList("230406", "230413", "230420", "230427");
33-
// TranslateUtil.translateTitle(NUMBER_LIST);
34+
List<String> NUMBER_LIST = Arrays.asList("201015");
35+
TranslateUtil.translateTitleWithScriptFile(NUMBER_LIST, "script");
3436

3537
// TranslateUtil.mergeScriptContentWx(folderName);
3638

@@ -40,7 +42,6 @@ public static void main(String[] args) {
4042
}
4143

4244
/**
43-
*
4445
* @param str
4546
* @return
4647
*/
@@ -90,8 +91,54 @@ public static List<String> translateTitle(List<String> folderNameList, String fi
9091
// titleList.add(stringList.get(0));
9192
titleList.add(getTitleString(stringList));
9293
}
94+
}
95+
96+
String textTitleList = titleList.stream().map(String::valueOf).collect(Collectors.joining("\r\n"));
97+
List<String> stringListTitleCn = TranslatorTextUtil.translatorText(textTitleList);
98+
String[] arr = new String[0];
99+
for (int i = 0; i < stringListTitleCn.size(); i++) {
100+
String temp = stringListTitleCn.get(i);
101+
arr = temp.split("\r\n");
102+
}
103+
104+
List<String> titleCnList = Arrays.asList(arr);
105+
List<String> newList = new ArrayList<>();
106+
String titleTranslate;
107+
for (int i = 0; i < arr.length; i++) {
108+
titleTranslate = folderNameList.get(i).substring(2) + "\t" + titleList.get(i) + "\t" + arr[i];
109+
System.out.println(titleTranslate);
110+
newList.add(titleTranslate);
111+
}
112+
113+
// String srcFileNameCn = BbcConstants.ROOT_FOLDER_NAME + File.separator + "title.txt";
114+
// 写中文翻译文本
115+
// CdFileUtils.writeToFile(srcFileNameCn, newList);
116+
return titleCnList;
117+
}
118+
119+
public static List<String> translateTitleWithScriptFile(List<String> folderNameList, String fileName) {
120+
// if (fileName == null) {
121+
// fileName = "script_raw";
122+
// }
123+
// 220303_script.txt
124+
// if (fileName.endsWith("_script.txt")) {
125+
// // TODO
126+
// }
93127

128+
// 6 Minute English
129+
// word-for-word transcript
130+
List<String> titleList = new ArrayList<>();
131+
for (String folderName : folderNameList) {
132+
fileName = folderName + "_script"; // TODO 指定
133+
String srcFileName = CommonUtil.getFullPathFileName(folderName, fileName, ".txt");
134+
List<String> stringList = CdFileUtils.readFileContent(srcFileName);
94135

136+
String title;
137+
int size = stringList.size();
138+
if (CollectionUtil.isNotEmpty(stringList)) {
139+
// titleList.add(stringList.get(0));
140+
titleList.add(getTitleString(stringList));
141+
}
95142
}
96143

97144
String textTitleList = titleList.stream().map(String::valueOf).collect(Collectors.joining("\r\n"));

free-apps/src/main/java/com/coderdream/freeapps/util/proxy/MultiThreadGenOneScriptTextExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void initTestArr() {
5757
List<DownloadInfoEntity> downloadInfoEntityListTemp = new ArrayList<>();
5858
if (test) {
5959
DownloadInfoEntity infoEntity = new DownloadInfoEntity();
60-
String ep = "240530";
60+
String ep = "240613";
6161
infoEntity.setFileUrl(
6262
"https://www.bbc.co.uk/learningenglish/english/features/6-minute-english_2024/ep-" + ep + "");
6363
infoEntity.setPath("D:/14_LearnEnglish/6MinuteEnglish/2024/" + ep + "/");

free-apps/src/main/resources/data/bbc/pdf_names.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,4 @@
123123
240523_how_bubble_tea_got_its_bubbles.pdf
124124
240530_too_old_to_have_a_baby.pdf
125125
240606_e-rickshaws_driving_away_pollution.pdf
126+
240613_how_names_can_tell_painful_stories.pdf
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
240530
1+
201001
2+
201008
3+
201022
4+
201029
Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,5 @@
1-
200102
2-
200109
3-
200116
4-
200123
5-
200130
6-
200206
7-
200213
8-
200220
9-
200227
10-
200305
11-
200312
12-
200319
13-
200326
14-
200402
15-
200409
16-
200416
17-
200423
18-
200430
19-
200507
20-
200514
21-
200521
22-
200528
23-
200604
24-
200611
25-
200618
26-
200625
27-
200702
28-
200709
29-
200716
30-
200723
31-
200730
32-
200806
33-
200813
34-
200820
35-
200827
36-
200903
37-
200910
38-
200917
39-
200924
401
201001
412
201008
423
201015
434
201022
445
201029
45-
201105
46-
201112
47-
201119
48-
201126
49-
201203
50-
201210
51-
201217
52-
201224
53-
201231
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
jacob kirkegaard
3+
we use the expressions, ‘in the long term’ and in the short term to talk about what will happen over a long or short period of time. in the short term, - over a short period of time - elisabeth thinks it’s too early to talk about a jobs recovery.
4+
and i said b) one third of a billion.
5+
denmark enjoys labour flexibility because it’s easy for bosses to hire and fire – employ someone and release them from employment, meaning there’s no such thing as a job for life – one that you can stay in all your working life.
6+
well i think in the short term it does feel like we are not yet in a place where we can talk about recovery and rebuilding completely – we’re still gonna see the ramifications, the impact and the ripple effect of all this for months to come.
7+
denmark provides one of the world’s most generous unemployment payouts but in return citizens are expected to commit to any job or training the government thinks would be beneficial.
8+
elisabeth reynolds
9+
according to elisabeth, the problem is that many of the government measures put in place to support jobs are not sustainable in the long term. she says more radical change is needed.
10+
that’s all we have time for, but come back soon for more trending topics and useful vocabulary here at 6 minute english from bbc learning english. bye for now!
11+
jacob kirkegaard, senior fellow at the peterson institute in washington, is himself a dane. here he explains to bbc business daily how the model works:
12+
but lavish – expensive and generous - benefits from the government, who also pay for upskilling or training in new skills, means that danish unemployment is rarely out of control.
13+
Marianna Spring
14+
we’ll be asking whether one of the world’s smallest – and richest – countries, denmark, might hold the answer.
15+
we’ve been discussing predictions of mass unemployment in the short term – or over a short time period, caused by the coronavirus pandemic. it also seems we will be experiencing the ripple effects – series of consequences, of the virus for a long time to come.
16+
…and thereby preventing unemployment – which reminds me of your quiz question, neil.
17+
yes, i asked you how many people were predicted to lose their jobs to the covid pandemic.
18+
bye!
19+
Neil
20+
hello. this is 6 minute english from bbc learning english. i’m neil.
21+
sam
22+
she also warns that we haven’t yet experienced the full impact or ramifications of the pandemic. like throwing a stone into water, these consequences create a ripple effect – a situation where one event causes a series of effects which spread and produce further effects.
23+
well, fortunately it’s the slightly lower, but still worrying, figure of, one quarter of a billion people.
24+
it’s very easy to hire and fire people in denmark – it doesn’t cost you anything and you don’t have sort of a guaranteed job for life once you get a permanent contract, which is the situation in many other continental european countries… so it combines labour market flexibility with employment security… namely the idea that people, if they lose their job, they know that they can find another job even if that requires them to pick up new skills – because that upskilling - or reskilling - is going to be made available to them, partly through very lavish government subsides.
25+
ok, sam, we’ll come back to that later. now, mass unemployment – millions of people losing their jobs due to the covid pandemic – has left the world facing an enormous jobs challenge. elisabeth reynolds, of the massachusetts institute of technology, is author of the report ‘work of the future’. here she is talking to bbc world service programme, business daily, about the current situation:
26+
for those daily workers without savings to pay the rent and feed their families it has been especially stressful. each job loss is a potential personal tragedy.
27+
neil
28+
wow, those numbers do really look gloomy! i’ll say b) one third of a billion people unemployed around the world.
29+
you and i are lucky, sam, because we can do our jobs remotely, working from home. there are some downsides, though - like not being able to meet up with friends or share ideas with colleagues.
30+
but the coronavirus pandemic has caused millions of people to lose their job and forced thousand more out of work temporarily with no idea if their job will still be there when they return.
31+
and of course, we’ll be learning some new vocabulary as well. but first it’s time for our quiz question. one man who knows a lot about jobs is brad smith, president of microsoft, a company employing over 150 thousand workers. he’s made gloomy predictions about the number of people out of work – but how many people does he predict will be left unemployed this year as a result of the coronavirus pandemic? is it: a) one quarter of a billion people?; b) one third of a billion people? or c) half a billion people?
32+
and going out for lunch!
33+
and i’m sam.
34+
of course the big question is – how? one proposed solution is the danish model. this balances citizens’ rights and duties.
35+
but citizens also have the security of lavish – generous and expensive – benefits, and the government will also pay for worker upskilling - training to learn new skills making them better at their jobs...
36+
in this programme we’ll be assessing the post-covid job landscape and asking whether a radical new approach is needed to prevent global mass unemployment.
37+
one solution to mass unemployment may be the danish model, were the power to hire or fire – employ someone or make them unemployed – means there are not many jobs for life – jobs you can do all your working life.
38+
Sam
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
jacob kirkegaard
3+
we use the expressions, ‘in the long term’ and in the short term to talk about what will happen over a long or short period of time. in the short term, - over a short period of time - elisabeth thinks it’s too early to talk about a jobs recovery.
4+
Claire Bates
5+
and i said b) one third of a billion.
6+
denmark enjoys labour flexibility because it’s easy for bosses to hire and fire – employ someone and release them from employment, meaning there’s no such thing as a job for life – one that you can stay in all your working life.
7+
well i think in the short term it does feel like we are not yet in a place where we can talk about recovery and rebuilding completely – we’re still gonna see the ramifications, the impact and the ripple effect of all this for months to come.
8+
denmark provides one of the world’s most generous unemployment payouts but in return citizens are expected to commit to any job or training the government thinks would be beneficial.
9+
elisabeth reynolds
10+
Keren Mimran
11+
according to elisabeth, the problem is that many of the government measures put in place to support jobs are not sustainable in the long term. she says more radical change is needed.
12+
that’s all we have time for, but come back soon for more trending topics and useful vocabulary here at 6 minute english from bbc learning english. bye for now!
13+
jacob kirkegaard, senior fellow at the peterson institute in washington, is himself a dane. here he explains to bbc business daily how the model works:
14+
but lavish – expensive and generous - benefits from the government, who also pay for upskilling or training in new skills, means that danish unemployment is rarely out of control.
15+
we’ll be asking whether one of the world’s smallest – and richest – countries, denmark, might hold the answer.
16+
we’ve been discussing predictions of mass unemployment in the short term – or over a short time period, caused by the coronavirus pandemic. it also seems we will be experiencing the ripple effects – series of consequences, of the virus for a long time to come.
17+
…and thereby preventing unemployment – which reminds me of your quiz question, neil.
18+
yes, i asked you how many people were predicted to lose their jobs to the covid pandemic.
19+
bye!
20+
marianna spring
21+
Neil
22+
hello. this is 6 minute english from bbc learning english. i’m neil.
23+
sam
24+
she also warns that we haven’t yet experienced the full impact or ramifications of the pandemic. like throwing a stone into water, these consequences create a ripple effect – a situation where one event causes a series of effects which spread and produce further effects.
25+
well, fortunately it’s the slightly lower, but still worrying, figure of, one quarter of a billion people.
26+
it’s very easy to hire and fire people in denmark – it doesn’t cost you anything and you don’t have sort of a guaranteed job for life once you get a permanent contract, which is the situation in many other continental european countries… so it combines labour market flexibility with employment security… namely the idea that people, if they lose their job, they know that they can find another job even if that requires them to pick up new skills – because that upskilling - or reskilling - is going to be made available to them, partly through very lavish government subsides.
27+
ok, sam, we’ll come back to that later. now, mass unemployment – millions of people losing their jobs due to the covid pandemic – has left the world facing an enormous jobs challenge. elisabeth reynolds, of the massachusetts institute of technology, is author of the report ‘work of the future’. here she is talking to bbc world service programme, business daily, about the current situation:
28+
for those daily workers without savings to pay the rent and feed their families it has been especially stressful. each job loss is a potential personal tragedy.
29+
neil
30+
wow, those numbers do really look gloomy! i’ll say b) one third of a billion people unemployed around the world.
31+
you and i are lucky, sam, because we can do our jobs remotely, working from home. there are some downsides, though - like not being able to meet up with friends or share ideas with colleagues.
32+
but the coronavirus pandemic has caused millions of people to lose their job and forced thousand more out of work temporarily with no idea if their job will still be there when they return.
33+
and of course, we’ll be learning some new vocabulary as well. but first it’s time for our quiz question. one man who knows a lot about jobs is brad smith, president of microsoft, a company employing over 150 thousand workers. he’s made gloomy predictions about the number of people out of work – but how many people does he predict will be left unemployed this year as a result of the coronavirus pandemic? is it: a) one quarter of a billion people?; b) one third of a billion people? or c) half a billion people?
34+
and going out for lunch!
35+
and i’m sam.
36+
of course the big question is – how? one proposed solution is the danish model. this balances citizens’ rights and duties.
37+
but citizens also have the security of lavish – generous and expensive – benefits, and the government will also pay for worker upskilling - training to learn new skills making them better at their jobs...
38+
in this programme we’ll be assessing the post-covid job landscape and asking whether a radical new approach is needed to prevent global mass unemployment.
39+
one solution to mass unemployment may be the danish model, were the power to hire or fire – employ someone or make them unemployed – means there are not many jobs for life – jobs you can do all your working life.
40+
Sam

0 commit comments

Comments
 (0)