Commit 4ed4e8c 1 parent 13de354 commit 4ed4e8c Copy full SHA for 4ed4e8c
File tree 2 files changed +10
-4
lines changed
vxtiktok-cf-worker-proxy/src
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,17 @@ async function handleRequest(request) {
6
6
const url = new URL ( request . url )
7
7
const path = url . pathname
8
8
9
- const match = path . match ( / ^ \/ v i d \/ ( [ ^ \/ ] + ) \/ ( [ ^ \/ ] + ) \. m p 4 $ / )
9
+ let match = path . match ( / ^ \/ v i d \/ ( [ ^ \/ ] + ) \/ ( [ ^ \/ ] + ) $ / )
10
10
if ( ! match ) {
11
11
return new Response ( 'Invalid URL format' , { status : 400 } )
12
12
}
13
13
14
14
const author = match [ 1 ]
15
- const vid = match [ 2 ]
15
+ let vid = match [ 2 ]
16
+
17
+ if ( vid . endsWith ( '.mp4' ) ) {
18
+ vid = vid . slice ( 0 , - 4 )
19
+ }
16
20
17
21
const postLink = `https://www.tiktok.com/@${ author } /video/${ vid } `
18
22
const videoData = await downloadVideoFromPostURL ( postLink )
Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ def embed_tiktok(post_link):
173
173
if "slideshowData" not in videoInfo or videoInfo ["slideshowData" ] == None :
174
174
vFormat = findApiFormat (videoInfo )
175
175
176
- directURL = f"https://" + config .currentConfig ["MAIN" ]["domainName" ]+ "/vid/" + videoInfo ["author" ]["uniqueId" ]+ "/" + videoInfo ["id" ]+ ".mp4"
176
+ directURL = f"https://" + config .currentConfig ["MAIN" ]["domainName" ]+ "/vid/" + videoInfo ["author" ]["uniqueId" ]+ "/" + videoInfo ["id" ]# +".mp4"
177
177
else :
178
178
vFormat = {"width" : 1280 , "height" : 720 }
179
179
directURL = "https://" + config .currentConfig ["MAIN" ]["domainName" ]+ "/slideshow.mp4?url=" + post_link
@@ -184,8 +184,10 @@ def embed_tiktok(post_link):
184
184
def main ():
185
185
return redirect (config .currentConfig ["MAIN" ]["repoURL" ])
186
186
187
- @app .route ('/vid/<author>/<vid>.mp4 ' )
187
+ @app .route ('/vid/<author>/<vid>' )
188
188
def video (author , vid ):
189
+ if vid .endswith (".mp4" ):
190
+ vid = vid [:- 4 ]
189
191
post_link = f"https://www.tiktok.com/@{ author } /video/{ vid } "
190
192
videoData = downloadVideoFromPostURL (post_link )
191
193
if videoData == None :
You can’t perform that action at this time.
0 commit comments