only_ever_generator 0.4.8 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,11 +87,18 @@ class ParseSourceContent {
87
87
  return sanitizedBlocks;
88
88
  }
89
89
  parseVideoContent(data) {
90
- let timeCodes = [];
91
- data.map((e) => timeCodes.push(...e.children));
92
- let cleanedData = this.cleanTranscript(timeCodes);
93
- let collapsedData = this.collapseTimeCodes(cleanedData, 100);
94
- return collapsedData;
90
+ let finalChapters = [];
91
+ // let cleanedData = this.cleanTranscript(timeCodes);
92
+ data.forEach((e) => {
93
+ let combinedContent = this.cleanTranscript(e);
94
+ finalChapters.push({
95
+ "startTime": e.startTime,
96
+ "endTime": e.endTime,
97
+ "content": combinedContent,
98
+ "title": e.content
99
+ });
100
+ });
101
+ return finalChapters;
95
102
  }
96
103
  // remove content inside [] which denotes non-speech sounds
97
104
  isNonSpeech(content) {
@@ -100,24 +107,17 @@ class ParseSourceContent {
100
107
  }
101
108
  // remove non-essential content
102
109
  cleanTranscript(data) {
103
- // Clean the transcript by removing non-speech content, normalizing whitespace, and keeping only necessary fields.
104
- const cleanedData = [];
105
- data.forEach(entry => {
106
- let content = (entry.content || '').trim();
107
- // Skip non-speech content
110
+ var _a;
111
+ let finalContent = '';
112
+ let children = (_a = data.children) !== null && _a !== void 0 ? _a : [];
113
+ children.forEach((e) => {
114
+ let content = (e.content || "").trim();
108
115
  if (this.isNonSpeech(content))
109
116
  return;
110
- // Normalize whitespace in content
111
117
  content = content.replace(/\s+/g, ' ');
112
- // Only keep start_time, end_time, content
113
- const currentEntry = {
114
- start_time: entry.startTime,
115
- end_time: entry.endTime,
116
- content: content
117
- };
118
- cleanedData.push(currentEntry);
118
+ finalContent += content;
119
119
  });
120
- return cleanedData;
120
+ return finalContent;
121
121
  }
122
122
  // collapse the timecode to 30 seconds
123
123
  collapseTimeCodes(data, maxDuration = 30.0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "only_ever_generator",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "start": "npm run build && nodemon dist/index.js",
@@ -96,11 +96,20 @@ export class ParseSourceContent{
96
96
  }
97
97
 
98
98
  parseVideoContent(data: Array<any>){
99
- let timeCodes :Array<any> = [];
100
- data.map((e) => timeCodes.push(...e.children));
101
- let cleanedData = this.cleanTranscript(timeCodes);
102
- let collapsedData = this.collapseTimeCodes(cleanedData,100);
103
- return collapsedData;
99
+ let finalChapters :Array<any> = [];
100
+ // let cleanedData = this.cleanTranscript(timeCodes);
101
+ data.forEach((e)=>{
102
+ let combinedContent = this.cleanTranscript(e);
103
+ finalChapters.push({
104
+ "startTime": e.startTime,
105
+ "endTime": e.endTime,
106
+ "content": combinedContent,
107
+ "title": e.content
108
+ });
109
+ });
110
+
111
+ return finalChapters;
112
+
104
113
 
105
114
  }
106
115
 
@@ -111,30 +120,20 @@ export class ParseSourceContent{
111
120
  }
112
121
 
113
122
  // remove non-essential content
114
- cleanTranscript(data: Array<any>) {
115
- // Clean the transcript by removing non-speech content, normalizing whitespace, and keeping only necessary fields.
116
- const cleanedData = <any>[];
117
-
118
- data.forEach(entry => {
119
- let content = (entry.content || '').trim();
120
-
121
- // Skip non-speech content
122
- if (this.isNonSpeech(content)) return;
123
+ cleanTranscript(data: any) {
124
+ let finalContent = '';
125
+ let children = data.children ?? [];
123
126
 
124
- // Normalize whitespace in content
125
- content = content.replace(/\s+/g, ' ');
127
+ children.forEach((e:any)=>{
128
+ let content = (e.content || "").trim();
126
129
 
127
- // Only keep start_time, end_time, content
128
- const currentEntry = {
129
- start_time: entry.startTime,
130
- end_time: entry.endTime,
131
- content: content
132
- };
130
+ if(this.isNonSpeech(content)) return;
133
131
 
134
- cleanedData.push(currentEntry);
132
+ content = content.replace(/\s+/g, ' ');
133
+ finalContent += content;
135
134
  });
136
135
 
137
- return cleanedData;
136
+ return finalContent;
138
137
  }
139
138
 
140
139
  // collapse the timecode to 30 seconds