u-transkript 1.0.0__tar.gz
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.
- u_transkript-1.0.0/MANIFEST.in +13 -0
- u_transkript-1.0.0/PKG-INFO +284 -0
- u_transkript-1.0.0/README.md +229 -0
- u_transkript-1.0.0/__init__.py +145 -0
- u_transkript-1.0.0/ai_translator.py +280 -0
- u_transkript-1.0.0/build.py +144 -0
- u_transkript-1.0.0/cli.py +256 -0
- u_transkript-1.0.0/example.md +387 -0
- u_transkript-1.0.0/example.py +259 -0
- u_transkript-1.0.0/exceptions.py +138 -0
- u_transkript-1.0.0/fetched_transcript.py +308 -0
- u_transkript-1.0.0/formatters.py +261 -0
- u_transkript-1.0.0/pyproject.toml +6 -0
- u_transkript-1.0.0/quick_test.py +16 -0
- u_transkript-1.0.0/requirements.txt +2 -0
- u_transkript-1.0.0/setup.cfg +7 -0
- u_transkript-1.0.0/setup.py +82 -0
- u_transkript-1.0.0/transcript_list.py +225 -0
- u_transkript-1.0.0/u_transkript.egg-info/PKG-INFO +284 -0
- u_transkript-1.0.0/u_transkript.egg-info/SOURCES.txt +24 -0
- u_transkript-1.0.0/u_transkript.egg-info/dependency_links.txt +1 -0
- u_transkript-1.0.0/u_transkript.egg-info/not-zip-safe +1 -0
- u_transkript-1.0.0/u_transkript.egg-info/requires.txt +13 -0
- u_transkript-1.0.0/u_transkript.egg-info/top_level.txt +1 -0
- u_transkript-1.0.0/youtube_transcript.py +349 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: u-transkript
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: YouTube videolarını otomatik olarak çıkarıp AI ile çeviren güçlü Python kütüphanesi
|
|
5
|
+
Home-page: https://github.com/U-C4N/u-transkript
|
|
6
|
+
Author: U-C4N
|
|
7
|
+
Author-email: noreply@deuz.ai
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Documentation, https://github.com/U-C4N/u-transkript/blob/main/README.md
|
|
10
|
+
Project-URL: Source, https://github.com/U-C4N/u-transkript/
|
|
11
|
+
Project-URL: Tracker, https://github.com/U-C4N/u-transkript/issues
|
|
12
|
+
Keywords: youtube,transcript,translation,ai,gemini,subtitle,video,nlp,machine-learning,automation
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Education
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Classifier: Topic :: Multimedia :: Video
|
|
27
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
29
|
+
Requires-Python: >=3.7
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
Requires-Dist: requests>=2.25.1
|
|
32
|
+
Requires-Dist: lxml>=4.6.0
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov>=2.0; extra == "dev"
|
|
36
|
+
Requires-Dist: black>=21.0; extra == "dev"
|
|
37
|
+
Requires-Dist: flake8>=3.8; extra == "dev"
|
|
38
|
+
Requires-Dist: mypy>=0.800; extra == "dev"
|
|
39
|
+
Provides-Extra: docs
|
|
40
|
+
Requires-Dist: sphinx>=4.0; extra == "docs"
|
|
41
|
+
Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
|
|
42
|
+
Dynamic: author
|
|
43
|
+
Dynamic: author-email
|
|
44
|
+
Dynamic: classifier
|
|
45
|
+
Dynamic: description
|
|
46
|
+
Dynamic: description-content-type
|
|
47
|
+
Dynamic: home-page
|
|
48
|
+
Dynamic: keywords
|
|
49
|
+
Dynamic: license
|
|
50
|
+
Dynamic: project-url
|
|
51
|
+
Dynamic: provides-extra
|
|
52
|
+
Dynamic: requires-dist
|
|
53
|
+
Dynamic: requires-python
|
|
54
|
+
Dynamic: summary
|
|
55
|
+
|
|
56
|
+
# 🎬 U-Transkript
|
|
57
|
+
|
|
58
|
+
[](https://python.org)
|
|
59
|
+
[](LICENSE)
|
|
60
|
+
[](https://pypi.org/project/u-transkript/)
|
|
61
|
+
[](https://ai.google.dev/)
|
|
62
|
+
|
|
63
|
+
**Powerful Python library to automatically extract and translate YouTube videos with AI**
|
|
64
|
+
|
|
65
|
+
U-Transkript is a modern and user-friendly Python package that extracts transcripts (subtitles) from YouTube videos and translates them into your desired language using Google Gemini AI. It offers an excellent solution for education, research, content creation, and much more.
|
|
66
|
+
|
|
67
|
+
## ✨ Features
|
|
68
|
+
|
|
69
|
+
🤖 **AI-Powered Translation** - High-quality translations with Google Gemini AI
|
|
70
|
+
🌍 **Multi-Language Support** - Ability to translate into 50+ languages
|
|
71
|
+
📊 **Flexible Output Formats** - Get results in TXT, JSON, XML formats
|
|
72
|
+
🔗 **Method Chaining** - Easy to use with chained function calls
|
|
73
|
+
⚡ **Fast and Efficient** - Optimized performance
|
|
74
|
+
🛡️ **Secure** - Error handling and secure API calls
|
|
75
|
+
📝 **Detailed Documentation** - Comprehensive user guide
|
|
76
|
+
|
|
77
|
+
## 🚀 Quick Start
|
|
78
|
+
|
|
79
|
+
### Installation
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip install u-transkript
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Basic Usage
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from u_transkript import AITranscriptTranslator
|
|
89
|
+
|
|
90
|
+
# Create Translator
|
|
91
|
+
translator = AITranscriptTranslator("YOUR_GEMINI_API_KEY")
|
|
92
|
+
|
|
93
|
+
# Translate Video
|
|
94
|
+
result = translator.set_lang("English").translate_transcript("dQw4w9WgXcQ")
|
|
95
|
+
print(result)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Advanced Usage with Method Chaining
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
# Set all settings at once
|
|
102
|
+
result = (translator
|
|
103
|
+
.set_model("gemini-2.5-flash")
|
|
104
|
+
.set_lang("English")
|
|
105
|
+
.set_type("json")
|
|
106
|
+
.translate_transcript("VIDEO_ID"))
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 📖 Detailed Documentation
|
|
110
|
+
|
|
111
|
+
### Main Functions
|
|
112
|
+
|
|
113
|
+
| Function | Description | Example |
|
|
114
|
+
|-----------|----------|-------|
|
|
115
|
+
| `set_model(model)` | Set the Gemini model | `translator.set_model("gemini-2.5-flash")` |
|
|
116
|
+
| `set_api(api_key)` | Set the API key | `translator.set_api("YOUR_API_KEY")` |
|
|
117
|
+
| `set_lang(language)` | Set the target language | `translator.set_lang("English")` |
|
|
118
|
+
| `set_type(format)` | Set the output format | `translator.set_type("json")` |
|
|
119
|
+
| `translate_transcript(video_id)` | Main translation function | `translator.translate_transcript("VIDEO_ID")` |
|
|
120
|
+
|
|
121
|
+
### Supported Output Formats
|
|
122
|
+
|
|
123
|
+
#### 📄 TXT Format
|
|
124
|
+
```python
|
|
125
|
+
translator.set_type("txt")
|
|
126
|
+
# Output: "Hello, this is an example translation..."
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### 📋 JSON Format
|
|
130
|
+
```python
|
|
131
|
+
translator.set_type("json")
|
|
132
|
+
# Output: Structured JSON data (with metadata)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### 🏷️ XML Format
|
|
136
|
+
```python
|
|
137
|
+
translator.set_type("xml")
|
|
138
|
+
# Output: Full data structure in XML format
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Supported Languages
|
|
142
|
+
|
|
143
|
+
🇹🇷 Turkish • 🇺🇸 English • 🇪🇸 Spanish • 🇫🇷 French • 🇩🇪 German • 🇮🇹 Italian • 🇵🇹 Portuguese • 🇷🇺 Russian • 🇯🇵 Japanese • 🇰🇷 Korean • 🇨🇳 Chinese • 🇸🇦 Arabic
|
|
144
|
+
|
|
145
|
+
## 💡 Use Cases
|
|
146
|
+
|
|
147
|
+
### 📰 News Content
|
|
148
|
+
```python
|
|
149
|
+
# Translating news videos
|
|
150
|
+
result = translator.set_lang("English").translate_transcript("NEWS_VIDEO_ID")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 💼 Business Presentations
|
|
154
|
+
```python
|
|
155
|
+
# Translating technical presentations
|
|
156
|
+
result = translator.set_type("json").translate_transcript("PRESENTATION_ID")
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### 🎬 Content Creation
|
|
160
|
+
```python
|
|
161
|
+
# Translating YouTube content into different languages
|
|
162
|
+
video_ids = ["VIDEO1", "VIDEO2", "VIDEO3"]
|
|
163
|
+
for video_id in video_ids:
|
|
164
|
+
result = translator.set_lang("English").translate_transcript(video_id)
|
|
165
|
+
with open(f"{video_id}_en.txt", "w") as f:
|
|
166
|
+
f.write(result)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## 🔧 Advanced Features
|
|
170
|
+
|
|
171
|
+
### Custom Prompt Usage
|
|
172
|
+
```python
|
|
173
|
+
custom_prompt = """
|
|
174
|
+
Please translate this text into {language}:
|
|
175
|
+
- Preserve technical terms
|
|
176
|
+
- Use natural language
|
|
177
|
+
- Maintain context
|
|
178
|
+
|
|
179
|
+
Text: {text}
|
|
180
|
+
"""
|
|
181
|
+
|
|
182
|
+
result = translator.translate_transcript(
|
|
183
|
+
"VIDEO_ID",
|
|
184
|
+
custom_prompt=custom_prompt
|
|
185
|
+
)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Batch Processing
|
|
189
|
+
```python
|
|
190
|
+
videos = ["VIDEO1", "VIDEO2", "VIDEO3"]
|
|
191
|
+
results = []
|
|
192
|
+
|
|
193
|
+
for video in videos:
|
|
194
|
+
try:
|
|
195
|
+
result = translator.set_lang("English").translate_transcript(video)
|
|
196
|
+
results.append({"video": video, "translation": result})
|
|
197
|
+
except Exception as e:
|
|
198
|
+
results.append({"video": video, "error": str(e)})
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Saving to File
|
|
202
|
+
```python
|
|
203
|
+
# Saving in JSON format
|
|
204
|
+
result = translator.set_type("json").translate_transcript("VIDEO_ID")
|
|
205
|
+
with open("translation.json", "w", encoding="utf-8") as f:
|
|
206
|
+
f.write(result)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
## 📊 Performance
|
|
211
|
+
|
|
212
|
+
| Model | Speed | Quality | Usage |
|
|
213
|
+
|-------|-----|--------|----------|
|
|
214
|
+
| `gemini-2.0-flash-exp` | ⚡⚡⚡ | ⭐⭐⭐ | Fast translations |
|
|
215
|
+
| `gemini-2.5-flash` | ⚡⚡ | ⭐⭐⭐⭐ | Balanced performance |
|
|
216
|
+
| `gemini-pro` | ⚡ | ⭐⭐⭐⭐⭐ | Highest quality |
|
|
217
|
+
|
|
218
|
+
## 🔍 Troubleshooting
|
|
219
|
+
|
|
220
|
+
### Common Errors
|
|
221
|
+
|
|
222
|
+
**API Key Error**
|
|
223
|
+
```python
|
|
224
|
+
# ❌ Incorrect
|
|
225
|
+
translator = AITranscriptTranslator("")
|
|
226
|
+
|
|
227
|
+
# ✅ Correct
|
|
228
|
+
translator = AITranscriptTranslator("VALID_API_KEY")
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Video Not Found**
|
|
232
|
+
```python
|
|
233
|
+
# Ensure the Video ID is correct
|
|
234
|
+
video_id = "dQw4w9WgXcQ" # 11 characters
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Language Error**
|
|
238
|
+
```python
|
|
239
|
+
# ❌ Incorrect
|
|
240
|
+
translator.set_lang("en")
|
|
241
|
+
|
|
242
|
+
# ✅ Correct
|
|
243
|
+
translator.set_lang("English")
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Debug Mode
|
|
247
|
+
```python
|
|
248
|
+
import logging
|
|
249
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
250
|
+
|
|
251
|
+
try:
|
|
252
|
+
result = translator.translate_transcript("VIDEO_ID")
|
|
253
|
+
except Exception as e:
|
|
254
|
+
print(f"Error: {e}")
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## 📈 Roadmap
|
|
258
|
+
|
|
259
|
+
- [ ] **v1.1.0** - Batch processing support
|
|
260
|
+
- [ ] **v1.2.0** - Caching system
|
|
261
|
+
- [ ] **v1.3.0** - CLI interface
|
|
262
|
+
- [ ] **v1.4.0** - Web interface
|
|
263
|
+
- [ ] **v1.5.0** - Support for more AI models
|
|
264
|
+
|
|
265
|
+
## 🤝 Contributing
|
|
266
|
+
|
|
267
|
+
We welcome your contributions!
|
|
268
|
+
|
|
269
|
+
1. Fork it
|
|
270
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
271
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
272
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
273
|
+
5. Open a Pull Request
|
|
274
|
+
|
|
275
|
+
## 📄 License
|
|
276
|
+
|
|
277
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
## 📞 Contact
|
|
281
|
+
|
|
282
|
+
- **GitHub**: [u-transkript](https://github.com/U-C4N/u-transkript)
|
|
283
|
+
- **PyPI**: [u-transkript](https://pypi.org/project/u-transkript/)
|
|
284
|
+
- **Documentation**: [example.md](example.md)
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# 🎬 U-Transkript
|
|
2
|
+
|
|
3
|
+
[](https://python.org)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://pypi.org/project/u-transkript/)
|
|
6
|
+
[](https://ai.google.dev/)
|
|
7
|
+
|
|
8
|
+
**Powerful Python library to automatically extract and translate YouTube videos with AI**
|
|
9
|
+
|
|
10
|
+
U-Transkript is a modern and user-friendly Python package that extracts transcripts (subtitles) from YouTube videos and translates them into your desired language using Google Gemini AI. It offers an excellent solution for education, research, content creation, and much more.
|
|
11
|
+
|
|
12
|
+
## ✨ Features
|
|
13
|
+
|
|
14
|
+
🤖 **AI-Powered Translation** - High-quality translations with Google Gemini AI
|
|
15
|
+
🌍 **Multi-Language Support** - Ability to translate into 50+ languages
|
|
16
|
+
📊 **Flexible Output Formats** - Get results in TXT, JSON, XML formats
|
|
17
|
+
🔗 **Method Chaining** - Easy to use with chained function calls
|
|
18
|
+
⚡ **Fast and Efficient** - Optimized performance
|
|
19
|
+
🛡️ **Secure** - Error handling and secure API calls
|
|
20
|
+
📝 **Detailed Documentation** - Comprehensive user guide
|
|
21
|
+
|
|
22
|
+
## 🚀 Quick Start
|
|
23
|
+
|
|
24
|
+
### Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install u-transkript
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Basic Usage
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from u_transkript import AITranscriptTranslator
|
|
34
|
+
|
|
35
|
+
# Create Translator
|
|
36
|
+
translator = AITranscriptTranslator("YOUR_GEMINI_API_KEY")
|
|
37
|
+
|
|
38
|
+
# Translate Video
|
|
39
|
+
result = translator.set_lang("English").translate_transcript("dQw4w9WgXcQ")
|
|
40
|
+
print(result)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Advanced Usage with Method Chaining
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
# Set all settings at once
|
|
47
|
+
result = (translator
|
|
48
|
+
.set_model("gemini-2.5-flash")
|
|
49
|
+
.set_lang("English")
|
|
50
|
+
.set_type("json")
|
|
51
|
+
.translate_transcript("VIDEO_ID"))
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 📖 Detailed Documentation
|
|
55
|
+
|
|
56
|
+
### Main Functions
|
|
57
|
+
|
|
58
|
+
| Function | Description | Example |
|
|
59
|
+
|-----------|----------|-------|
|
|
60
|
+
| `set_model(model)` | Set the Gemini model | `translator.set_model("gemini-2.5-flash")` |
|
|
61
|
+
| `set_api(api_key)` | Set the API key | `translator.set_api("YOUR_API_KEY")` |
|
|
62
|
+
| `set_lang(language)` | Set the target language | `translator.set_lang("English")` |
|
|
63
|
+
| `set_type(format)` | Set the output format | `translator.set_type("json")` |
|
|
64
|
+
| `translate_transcript(video_id)` | Main translation function | `translator.translate_transcript("VIDEO_ID")` |
|
|
65
|
+
|
|
66
|
+
### Supported Output Formats
|
|
67
|
+
|
|
68
|
+
#### 📄 TXT Format
|
|
69
|
+
```python
|
|
70
|
+
translator.set_type("txt")
|
|
71
|
+
# Output: "Hello, this is an example translation..."
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### 📋 JSON Format
|
|
75
|
+
```python
|
|
76
|
+
translator.set_type("json")
|
|
77
|
+
# Output: Structured JSON data (with metadata)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### 🏷️ XML Format
|
|
81
|
+
```python
|
|
82
|
+
translator.set_type("xml")
|
|
83
|
+
# Output: Full data structure in XML format
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Supported Languages
|
|
87
|
+
|
|
88
|
+
🇹🇷 Turkish • 🇺🇸 English • 🇪🇸 Spanish • 🇫🇷 French • 🇩🇪 German • 🇮🇹 Italian • 🇵🇹 Portuguese • 🇷🇺 Russian • 🇯🇵 Japanese • 🇰🇷 Korean • 🇨🇳 Chinese • 🇸🇦 Arabic
|
|
89
|
+
|
|
90
|
+
## 💡 Use Cases
|
|
91
|
+
|
|
92
|
+
### 📰 News Content
|
|
93
|
+
```python
|
|
94
|
+
# Translating news videos
|
|
95
|
+
result = translator.set_lang("English").translate_transcript("NEWS_VIDEO_ID")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 💼 Business Presentations
|
|
99
|
+
```python
|
|
100
|
+
# Translating technical presentations
|
|
101
|
+
result = translator.set_type("json").translate_transcript("PRESENTATION_ID")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 🎬 Content Creation
|
|
105
|
+
```python
|
|
106
|
+
# Translating YouTube content into different languages
|
|
107
|
+
video_ids = ["VIDEO1", "VIDEO2", "VIDEO3"]
|
|
108
|
+
for video_id in video_ids:
|
|
109
|
+
result = translator.set_lang("English").translate_transcript(video_id)
|
|
110
|
+
with open(f"{video_id}_en.txt", "w") as f:
|
|
111
|
+
f.write(result)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 🔧 Advanced Features
|
|
115
|
+
|
|
116
|
+
### Custom Prompt Usage
|
|
117
|
+
```python
|
|
118
|
+
custom_prompt = """
|
|
119
|
+
Please translate this text into {language}:
|
|
120
|
+
- Preserve technical terms
|
|
121
|
+
- Use natural language
|
|
122
|
+
- Maintain context
|
|
123
|
+
|
|
124
|
+
Text: {text}
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
result = translator.translate_transcript(
|
|
128
|
+
"VIDEO_ID",
|
|
129
|
+
custom_prompt=custom_prompt
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Batch Processing
|
|
134
|
+
```python
|
|
135
|
+
videos = ["VIDEO1", "VIDEO2", "VIDEO3"]
|
|
136
|
+
results = []
|
|
137
|
+
|
|
138
|
+
for video in videos:
|
|
139
|
+
try:
|
|
140
|
+
result = translator.set_lang("English").translate_transcript(video)
|
|
141
|
+
results.append({"video": video, "translation": result})
|
|
142
|
+
except Exception as e:
|
|
143
|
+
results.append({"video": video, "error": str(e)})
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Saving to File
|
|
147
|
+
```python
|
|
148
|
+
# Saving in JSON format
|
|
149
|
+
result = translator.set_type("json").translate_transcript("VIDEO_ID")
|
|
150
|
+
with open("translation.json", "w", encoding="utf-8") as f:
|
|
151
|
+
f.write(result)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
## 📊 Performance
|
|
156
|
+
|
|
157
|
+
| Model | Speed | Quality | Usage |
|
|
158
|
+
|-------|-----|--------|----------|
|
|
159
|
+
| `gemini-2.0-flash-exp` | ⚡⚡⚡ | ⭐⭐⭐ | Fast translations |
|
|
160
|
+
| `gemini-2.5-flash` | ⚡⚡ | ⭐⭐⭐⭐ | Balanced performance |
|
|
161
|
+
| `gemini-pro` | ⚡ | ⭐⭐⭐⭐⭐ | Highest quality |
|
|
162
|
+
|
|
163
|
+
## 🔍 Troubleshooting
|
|
164
|
+
|
|
165
|
+
### Common Errors
|
|
166
|
+
|
|
167
|
+
**API Key Error**
|
|
168
|
+
```python
|
|
169
|
+
# ❌ Incorrect
|
|
170
|
+
translator = AITranscriptTranslator("")
|
|
171
|
+
|
|
172
|
+
# ✅ Correct
|
|
173
|
+
translator = AITranscriptTranslator("VALID_API_KEY")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Video Not Found**
|
|
177
|
+
```python
|
|
178
|
+
# Ensure the Video ID is correct
|
|
179
|
+
video_id = "dQw4w9WgXcQ" # 11 characters
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Language Error**
|
|
183
|
+
```python
|
|
184
|
+
# ❌ Incorrect
|
|
185
|
+
translator.set_lang("en")
|
|
186
|
+
|
|
187
|
+
# ✅ Correct
|
|
188
|
+
translator.set_lang("English")
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Debug Mode
|
|
192
|
+
```python
|
|
193
|
+
import logging
|
|
194
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
195
|
+
|
|
196
|
+
try:
|
|
197
|
+
result = translator.translate_transcript("VIDEO_ID")
|
|
198
|
+
except Exception as e:
|
|
199
|
+
print(f"Error: {e}")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## 📈 Roadmap
|
|
203
|
+
|
|
204
|
+
- [ ] **v1.1.0** - Batch processing support
|
|
205
|
+
- [ ] **v1.2.0** - Caching system
|
|
206
|
+
- [ ] **v1.3.0** - CLI interface
|
|
207
|
+
- [ ] **v1.4.0** - Web interface
|
|
208
|
+
- [ ] **v1.5.0** - Support for more AI models
|
|
209
|
+
|
|
210
|
+
## 🤝 Contributing
|
|
211
|
+
|
|
212
|
+
We welcome your contributions!
|
|
213
|
+
|
|
214
|
+
1. Fork it
|
|
215
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
216
|
+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
217
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
218
|
+
5. Open a Pull Request
|
|
219
|
+
|
|
220
|
+
## 📄 License
|
|
221
|
+
|
|
222
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
## 📞 Contact
|
|
226
|
+
|
|
227
|
+
- **GitHub**: [u-transkript](https://github.com/U-C4N/u-transkript)
|
|
228
|
+
- **PyPI**: [u-transkript](https://pypi.org/project/u-transkript/)
|
|
229
|
+
- **Documentation**: [example.md](example.md)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""
|
|
2
|
+
U-Transkript - YouTube videolarını AI ile çeviren Python paketi
|
|
3
|
+
|
|
4
|
+
Bu paket, YouTube videolarından transcript çıkararak Google Gemini AI ile
|
|
5
|
+
istediğiniz dile çeviren modern ve kullanıcı dostu bir çözüm sunar.
|
|
6
|
+
|
|
7
|
+
Temel Kullanım:
|
|
8
|
+
from u_transkript import AITranscriptTranslator
|
|
9
|
+
|
|
10
|
+
translator = AITranscriptTranslator("YOUR_GEMINI_API_KEY")
|
|
11
|
+
result = translator.set_lang("Turkish").translate_transcript("VIDEO_ID")
|
|
12
|
+
|
|
13
|
+
Özellikler:
|
|
14
|
+
- AI destekli çeviri (Google Gemini)
|
|
15
|
+
- 50+ dil desteği
|
|
16
|
+
- TXT, JSON, XML çıktı formatları
|
|
17
|
+
- Method chaining desteği
|
|
18
|
+
- Hata yönetimi
|
|
19
|
+
- Yüksek performans
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from .youtube_transcript import YouTubeTranscriptApi
|
|
23
|
+
from .transcript_list import TranscriptList
|
|
24
|
+
from .fetched_transcript import FetchedTranscript
|
|
25
|
+
from .ai_translator import AITranscriptTranslator
|
|
26
|
+
from .exceptions import (
|
|
27
|
+
TranscriptRetrievalError,
|
|
28
|
+
VideoUnavailable,
|
|
29
|
+
TranscriptNotFound,
|
|
30
|
+
TranscriptDisabled,
|
|
31
|
+
NoTranscriptFound,
|
|
32
|
+
NotTranslatable,
|
|
33
|
+
TranslationLanguageNotAvailable,
|
|
34
|
+
CookiePathInvalid,
|
|
35
|
+
CookiesInvalid,
|
|
36
|
+
FailedToCreateConsentCookie,
|
|
37
|
+
NoTranscriptAvailable,
|
|
38
|
+
TooManyRequests
|
|
39
|
+
)
|
|
40
|
+
from .formatters import (
|
|
41
|
+
Formatter,
|
|
42
|
+
PrettyPrintFormatter,
|
|
43
|
+
JSONFormatter,
|
|
44
|
+
TextFormatter,
|
|
45
|
+
SRTFormatter,
|
|
46
|
+
VTTFormatter
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
__version__ = "1.0.0"
|
|
50
|
+
__author__ = "U-Transkript Team"
|
|
51
|
+
__email__ = "contact@u-transkript.com"
|
|
52
|
+
__description__ = "YouTube videolarını otomatik olarak çıkarıp AI ile çeviren güçlü Python kütüphanesi"
|
|
53
|
+
__url__ = "https://github.com/username/u-transkript"
|
|
54
|
+
|
|
55
|
+
# Ana sınıf ve fonksiyonları dışa aktar
|
|
56
|
+
__all__ = [
|
|
57
|
+
# Ana AI çeviri sınıfı
|
|
58
|
+
'AITranscriptTranslator',
|
|
59
|
+
|
|
60
|
+
# YouTube transcript API sınıfları
|
|
61
|
+
'YouTubeTranscriptApi',
|
|
62
|
+
'TranscriptList',
|
|
63
|
+
'FetchedTranscript',
|
|
64
|
+
|
|
65
|
+
# Hata sınıfları
|
|
66
|
+
'TranscriptRetrievalError',
|
|
67
|
+
'VideoUnavailable',
|
|
68
|
+
'TranscriptNotFound',
|
|
69
|
+
'TranscriptDisabled',
|
|
70
|
+
'NoTranscriptFound',
|
|
71
|
+
'NotTranslatable',
|
|
72
|
+
'TranslationLanguageNotAvailable',
|
|
73
|
+
'CookiePathInvalid',
|
|
74
|
+
'CookiesInvalid',
|
|
75
|
+
'FailedToCreateConsentCookie',
|
|
76
|
+
'NoTranscriptAvailable',
|
|
77
|
+
'TooManyRequests',
|
|
78
|
+
|
|
79
|
+
# Formatter sınıfları
|
|
80
|
+
'Formatter',
|
|
81
|
+
'PrettyPrintFormatter',
|
|
82
|
+
'JSONFormatter',
|
|
83
|
+
'TextFormatter',
|
|
84
|
+
'SRTFormatter',
|
|
85
|
+
'VTTFormatter'
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
# Paket bilgileri
|
|
89
|
+
__package_info__ = {
|
|
90
|
+
"name": "u-transkript",
|
|
91
|
+
"version": __version__,
|
|
92
|
+
"description": __description__,
|
|
93
|
+
"author": __author__,
|
|
94
|
+
"email": __email__,
|
|
95
|
+
"url": __url__,
|
|
96
|
+
"license": "MIT",
|
|
97
|
+
"python_requires": ">=3.7",
|
|
98
|
+
"keywords": [
|
|
99
|
+
"youtube", "transcript", "translation", "ai", "gemini",
|
|
100
|
+
"subtitle", "video", "nlp", "machine-learning", "automation"
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
def get_version():
|
|
105
|
+
"""Paket versiyonunu döndür."""
|
|
106
|
+
return __version__
|
|
107
|
+
|
|
108
|
+
def get_info():
|
|
109
|
+
"""Paket bilgilerini döndür."""
|
|
110
|
+
return __package_info__
|
|
111
|
+
|
|
112
|
+
# Hızlı başlangıç fonksiyonu
|
|
113
|
+
def quick_translate(video_id: str, api_key: str, target_language: str = "Turkish", output_type: str = "txt"):
|
|
114
|
+
"""
|
|
115
|
+
Hızlı çeviri fonksiyonu.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
video_id: YouTube video ID
|
|
119
|
+
api_key: Google Gemini API anahtarı
|
|
120
|
+
target_language: Hedef dil (varsayılan: "Turkish")
|
|
121
|
+
output_type: Çıktı formatı (varsayılan: "txt")
|
|
122
|
+
|
|
123
|
+
Returns:
|
|
124
|
+
Çevrilmiş transcript
|
|
125
|
+
|
|
126
|
+
Example:
|
|
127
|
+
result = quick_translate("dQw4w9WgXcQ", "YOUR_API_KEY", "Turkish")
|
|
128
|
+
"""
|
|
129
|
+
translator = AITranscriptTranslator(api_key)
|
|
130
|
+
return translator.set_lang(target_language).set_type(output_type).translate_transcript(video_id)
|
|
131
|
+
|
|
132
|
+
# Paket yüklendiğinde bilgi mesajı (opsiyonel)
|
|
133
|
+
def _show_welcome_message():
|
|
134
|
+
"""Paket yüklendiğinde hoş geldin mesajı göster."""
|
|
135
|
+
try:
|
|
136
|
+
import sys
|
|
137
|
+
if hasattr(sys, 'ps1'): # Etkileşimli modda çalışıyorsa
|
|
138
|
+
print(f"🎬 U-Transkript v{__version__} yüklendi!")
|
|
139
|
+
print("📖 Kullanım: from u_transkript import AITranscriptTranslator")
|
|
140
|
+
print("🔗 Dokümantasyon: https://github.com/username/u-transkript")
|
|
141
|
+
except:
|
|
142
|
+
pass # Hata durumunda sessizce geç
|
|
143
|
+
|
|
144
|
+
# Paket import edildiğinde hoş geldin mesajını göster (opsiyonel)
|
|
145
|
+
# _show_welcome_message()
|