问题
After successfully downloading the mp4 file using the Lua script on the Android phone, the system Videos cannot detect the 1.mp4 file, and the video cannot be found in TikTok to publish.
I downloaded 1.mp4 using a script.
I manually copied 1.mp4 to become copy.mp4.
1.mp4 cannot be detected by tiktok
copy.mp4 can be detected by tiktok
Neither file is hidden
I checked the permissions of two files :
-rw-rw---- root sdcard_ rw 6939904 2020-11-12 22:07 1. mp4
-rw-rw---- root sdcard_ rw 6939904 2020-11-12 22:15 copy. mp4
I don’t know why 1.mp4 is not found
Is there any way to make tiktok(Other apps) recognize 1.mp4
My code:
local http = require("socket.http")
severfileTXTpath = "https://ttmakemoney.oss-cn-hangzhou.aliyuncs.com/1.mp4"
localfileTXTpath = "/sdcard/Download/aliyunPZ/1/1.mp4"
local body, code = http.request(severfileTXTpath)
if not body then error(code) end
local f = assert(io.open(localfileTXTpath, 'wb'))
f:write(body)
f:close()
You can see the effect through the picture
Setelah salinan yang berjaya gagal, sistem video Android tidak dapat mengesan video copy.mp4, dan juga tidak dapat mencari video copy.mp4 yang akan diterbitkan di TikTok.
local ts = require("ts")
path1 = "/sdcard/Download/aliyunPZ/1/copy.mp4"
path2 = "/sdcard/Download/aliyunPZ/1/1.mp4"
os.execute("cp " ..path1.. " "..path2)
1.mp4 can be detected by tiktok
copy.mp4 cannot be detected by tiktok
I don't know what is wrong?
I checked the permissions of two files (adb):
-rw-rw---- root sdcard_rw 6939904 2020-11-13 20:21 1. mp4
-rw-rw---- root sdcard_rw 6939904 2020-11-14 1:54 copy. mp4
You can see the effect through the picture
回答1:
I think "body" in your script is actually the "OK status" being returned. Also, you attempting to open an https socket with http. This should do, just change URL and path.
#! /usr/bin/env lua
-- luarocks install luasocket
-- luarocks install luasec
-- local http = require( 'socket.http' )
local https = require( 'ssl.https' )
local ltn12 = require( 'ltn12' )
local URL = "https://raw.githubusercontent.com/doyousketch2/the3dPen/master/icon.png"
local path = "/home/sketch2/Downloads/icon.png"
local oput = io.open( path, 'wb' )
local ok, code, headers, text = https .request { url = URL, sink = ltn12.sink.file( oput ) }
print( 'ok:', ok )
print( 'code:', code, text )
if headers then
print( 'headers:' )
for i, v in pairs( headers ) do
print( ' ' ..i ..':', v )
end
end
based off of -- https://gist.github.com/Core-commits/0eaaa00eac5e89e68631fedd72831675
luasec is similar to luasocket, but allows https connections.
http://w3.impa.br/~diego/software/luasocket/http.html
http://w3.impa.br/~diego/software/luasocket/ltn12.html
来源:https://stackoverflow.com/questions/64828021/i-downloaded-the-mp4-file-using-lua-script-but-tiktokother-apps-cannot-find-t