我正试图在我的Google驱动器中播放一个音乐文件,但它大约300mb,所以Google不允许我使用这个链接直接下载它。
https://drive.google.com/uc?export=download&id=12cpUAP0wy8jyMD4-rjKJ23bicCJ29Cs-
有一个"google drive can't scan this file message“和”download and“按钮。然后我用Chrome查看了download anyway按钮,并看到了这个链接:
https://drive.google.com/uc?export=download&confirm=9iBg&id=12cpUAP0wy8jyMD4-rjKJ23bicCJ29Cs-
所以我试着用下面的func播放音频,它起作用了。
audioPlayer = AVPlayer(url: url)
但是,“无论如何下载”按钮中的url始终从confirm=9iBg更改为confirm=?这使得不可能再次播放音频,除非我必须转到我的代码并手动更改该id。对此有解决方案吗?谢谢!
发布于 2018-03-27 19:52:07
遗憾的是,在没有确认窗口的情况下无法完成此操作,令牌&confirm=9iBg&id=12cpUAP0wy8jyMD4-rjKJ23bicCJ29Cs-
很可能有到期日期,并且只能通过确认窗口进行续订。
发布于 2021-03-21 03:46:21
今天解决同样的问题时,我想出了一个解决方案。我正在使用shell从google drive自动下载文件。关键是设置cookie并从第一次下载尝试结果html页面内容中动态检索确认码:
printf "${WHITE}Downloading ${fileNames[$i]}${NC}\n"
curl -L -c mycookie -o temp "https://drive.google.com/uc?export=download&id=${fileLinks[$i]}"
filesize=$(wc -c temp | awk '{print $1}')
if [ $filesize -gt 10000 ]; then
printf "Finish downloading\n"
mv temp "${fileNames[$i]}.tar.gz"
else
content=$(cat temp)
for (( j=0; j<$filesize-10; j++)); do
if [ "${content:$j:8}" == "confirm=" ]; then
for (( k=0; k<10; k++)); do
if [ "${content:$j+8+$k:1}" == "&" ]; then
token=${content:$j+8:$k}
fi
done
fi
done
printf "Confirm downloading with token ${token}\n"
curl -L -b mycookie -o "${fileNames[$i]}.tar.gz" "https://drive.google.com/uc?export=download&confirm=${token}&id=${fileLinks[$i]}"
rm mycookie
rm temp
fi
https://stackoverflow.com/questions/48257984
复制相似问题