必应每日一图下载

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sleep 10
cd /root/pictures/ # 下载目录
for n in 0 1 2 3 4 5 6 7 # 0 今天 1 昨天 2 前天 以此类推......
do
tail=`curl "https://www.bing.com/HPImageArchive.aspx?format=js&idx=$n&n=1&mkt=ZH-CN" | grep -oP "th\?id=.*?jpg"`
image_name=`echo $tail | grep -oP 'OHR\.\K([a-zA-Z]+)'`'.jpg'
have=`ls $image_name`
if [ -z $have ]
then
hud=`echo $tail|sed 's/1920x1080/UHD/g'`
wget -O "${image_name}" https://bing.com/${hud}
echo "`date +%Y%m%d` ${image_name} 下载成功" >> download.log
fi
done

防止windows启动卡黑屏

故不使用网络驱动器

win+r打开taskschd.msc

添加启动任务计划

1-复制远程资源到本地

1
2
3
4
启动程序
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
启动参数
C:\Users\A\Pictures\update.ps1
1
2
3
# update.ps1
Copy-Item -Path Z:\pictures\*.jpg -Destination C:\Users\A\Pictures\ -Force
Copy-Item -Path Z:\music\* -Destination C:\Users\A\Music\ -Force

2-

1
2
3
4
5
启动程序
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
启动参数
-WindowStyle Hidden -File C:\A\Portable-Mode\VSCode\update.ps1
每7天执行一次
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# update.ps1
# Stop script on error
$ErrorActionPreference = 'Stop'

# Application folder
$AppDir = "C:\A\Portable-Mode\VSCode"
# Latest stable version (Win32-x64)
$Url = 'https://update.code.visualstudio.com/latest/win32-x64-archive/stable'
# Downloaded zip file
$DownloadFile = [System.IO.Path]::GetTempFileName() + '.zip'
# Download and unlock file
Invoke-WebRequest -uri $Url -OutFile $DownloadFile
Unblock-File $DownloadFile

# Unzip, overwrite code.exe
Expand-Archive -Force -Path $DownloadFile -DestinationPath $AppDir
# Remove temp file
Remove-Item -force -recurse $DownloadFile

Write-Output 'Finished.'

picture_2 格式化webp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cd /root/picture_2
git pull
images=$(ls *.png)

for image in $images
do
# -q 90 指定转换质量,经试验这个值效果和压缩率都不错
cwebp $image -q 70 -o ${image%.*}.webp
rm -rf $image
done
date=`date "+%Y-%m-%d %H:%M:%S"`

#提交
git add .
git commit -m "图片优化$(date)"
git push

oxox提交替换首页图

1
2
3
4
5
6
7
8
9
10
11
12
cd /root/oxox
git pull
date=`date "+%Y-%m-%d %H:%M:%S"`
# 替换首页图
today=`curl "https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=ZH-CN" | grep -oP "th\?id=.*?jpg"`
hud=`echo $today|sed 's/1920x1080/UHD/g'`
today="index_img: ""https://bing.com/${hud}"
sed -i '117c '"${today}"'' /root/oxox/_config.butterfly.yml
#提交
git add .
git commit -m "定时提交 @$(date)"
git push