Spaces:
Runtime error
Runtime error
fix: other durations will not affect to cache
Browse files
routes/ytApi/getPreview.py
CHANGED
|
@@ -33,19 +33,21 @@ def getPreview(request):
|
|
| 33 |
|
| 34 |
config = helpers.configFile()
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
return {
|
| 38 |
"status": "pass",
|
| 39 |
"details": {
|
| 40 |
"code": error_code,
|
| 41 |
"name":f"{urlcode}.{audioformat}",
|
| 42 |
-
"result": f"{config['url']}/static/previews/{
|
| 43 |
}
|
| 44 |
}
|
| 45 |
|
| 46 |
ydl_opts = {
|
| 47 |
'format': f'{audioformat}/{quality}audio/{quality}',
|
| 48 |
-
'outtmpl': f"{config['previews-path']}/{
|
| 49 |
'progress_hooks': [helpers.thisIsHook],
|
| 50 |
'download_ranges': download_range_func(None, [(0, duration)]),
|
| 51 |
'force_keyframes_at_cuts': True,
|
|
@@ -61,6 +63,6 @@ def getPreview(request):
|
|
| 61 |
"details": {
|
| 62 |
"code": error_code,
|
| 63 |
"name":f"{urlcode}.{audioformat}",
|
| 64 |
-
"result": f"{config['url']}/static/previews/{
|
| 65 |
}
|
| 66 |
}
|
|
|
|
| 33 |
|
| 34 |
config = helpers.configFile()
|
| 35 |
|
| 36 |
+
__filename = f"{urlcode}_dur{duration}.{audioformat}"
|
| 37 |
+
|
| 38 |
+
if os.path.exists(f"{config['previews-path']}/{__filename}"):
|
| 39 |
return {
|
| 40 |
"status": "pass",
|
| 41 |
"details": {
|
| 42 |
"code": error_code,
|
| 43 |
"name":f"{urlcode}.{audioformat}",
|
| 44 |
+
"result": f"{config['url']}/static/previews/{__filename}"
|
| 45 |
}
|
| 46 |
}
|
| 47 |
|
| 48 |
ydl_opts = {
|
| 49 |
'format': f'{audioformat}/{quality}audio/{quality}',
|
| 50 |
+
'outtmpl': f"{config['previews-path']}/{__filename}",
|
| 51 |
'progress_hooks': [helpers.thisIsHook],
|
| 52 |
'download_ranges': download_range_func(None, [(0, duration)]),
|
| 53 |
'force_keyframes_at_cuts': True,
|
|
|
|
| 63 |
"details": {
|
| 64 |
"code": error_code,
|
| 65 |
"name":f"{urlcode}.{audioformat}",
|
| 66 |
+
"result": f"{config['url']}/static/previews/{__filename}"
|
| 67 |
}
|
| 68 |
}
|