Skip to content

Commit b3d13a1

Browse files
committed
opt: move binary file to bin folder
1 parent 4c3c659 commit b3d13a1

7 files changed

Lines changed: 35 additions & 22 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**/obj
1+
**/obj/
22
web/cache
33
**/ffmpeg.exe
44
**/.vs/
@@ -25,3 +25,4 @@ web/cache
2525
**/*.bak*
2626
/web/*.html
2727
/test/
28+
/release/
File renamed without changes.
Binary file not shown.
File renamed without changes.

make.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@echo off
22
cls
33
set obj_folder=%~dp0obj
4-
set bin_folder=%~dp0
4+
set bin_folder=%~dp0bin
55
pushd %CD%
66
cd %~dp0
77
where cl >NUL 2>&1 1>NUL
@@ -27,7 +27,7 @@ if not exist src/getpage.c (
2727
goto :EOF
2828
)
2929
taskkill /f /im getpage.exe 2>NUL >NUL
30-
cl /nologo /W2 /Fo%obj_folder%\getpage.obj /Fe%bin_folder%getpage.exe src\getpage.c
30+
cl /nologo /W2 /Fo%obj_folder%\getpage.obj /Fe%bin_folder%\\getpage.exe src\getpage.c
3131
if %errorlevel% equ 0 (
3232
rem cls
3333
color 02

src/getpage.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,12 @@ int getTutorial(char *url, char *outfolder, char *cmd, int downall)
388388
// video tutorial
389389
if(strlen(info[1]))
390390
{
391-
char ytd[] = "..\\..\\yt-dlp --write-thumbnail --embed-metadata"
391+
char ytd[] = "..\\..\\bin\\yt-dlp --write-thumbnail --embed-metadata"
392392
" --cache-dir cache --write-link -f \"bv+ba\""
393393
" --progress --no-playlist --restrict-filenames --write-subs"
394394
" --audio-quality 10 --merge-output-format \"mp4\""
395395
" --sub-langs \"en-US.*,zh-Hans.*\" --convert-thumbnails png"
396-
" --ffmpeg-location ..\\..\\";
396+
" --ffmpeg-location ..\\..\\bin";
397397
sprintf(
398398
curlcmd,
399399
"@if not exist \"%s\\video.mp4\" "
@@ -484,8 +484,10 @@ int main(int argc, char* argv[])
484484
pp = fopen("..\\assets\\proxy.conf","r");
485485
if(pp != NULL)
486486
{
487-
fscanf(pp, "%110s", proxy);
488-
sprintf(proxyConf, "--proxy \"%110s\"", proxy);
487+
fscanf(pp, "%s", proxy);
488+
if(strlen(proxy)){
489+
sprintf(proxyConf, "--proxy \"%s\"", proxy);
490+
}
489491
fclose(pp);
490492
}
491493
// download guide page only

src/pixelmatorTutorialDownloader.js

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name pixelmatorTutorialDownloader
33
// @namespace http://tampermonkey.net/
4-
// @version 0.15
4+
// @version 0.16
55
// @description download pixcelmator pro tutorial resouces and youtube videos to local disk
66
// @author mooring@codernote.club
77
// @match https://www.pixelmator.com/tutorials/*
@@ -25,9 +25,15 @@ function getCategoryInfo(cmd, collect, init){
2525
moreless.click();
2626
}
2727
if(init){
28-
commands.push('cls');
29-
commands.push('@set getpage=%25~dp0\\..\\getpage.exe');
30-
commands.push(`@echo @set down=..\\yt-dlp --write-thumbnail --embed-metadata --cache-dir cache --write-link -f "bv+ba" --progress ${proxy?'--proxy "'+proxy+'"':''} --no-playlist --restrict-filenames --write-subs --audio-quality 10 --merge-output-format "mp4" --sub-langs "en-US.*,zh-Hans.*" --convert-thumbnails png --ffmpeg-location ..\\ ${init?'>':'>>'} %25~dp0\\${collect||category}_ytb.cmd`);
28+
commands.push(`cls`);
29+
commands.push(`@set proxy=`);
30+
commands.push(`@set proxy=${proxy}`);
31+
commands.push(`@set pxystr=`)
32+
commands.push(`@if "%25proxy%25" == "" @echo.>"%25~dp0assets\\proxy.conf"`);
33+
commands.push(`@if not "%25proxy%25" == "" @echo %25proxy%25>"%25~dp0assets\\proxy.conf"`);
34+
commands.push(`@if not "%25proxy%25" == "" @set pxystr=--proxy "%25proxy%25"`);
35+
commands.push(`@set getpage=%25~dp0..\\bin\\getpage.exe`);
36+
commands.push(`@echo @set down=..\\bin\\yt-dlp --write-thumbnail --embed-metadata --cache-dir cache --write-link -f "bv+ba" --progress %25pxystr%25 --no-playlist --restrict-filenames --write-subs --audio-quality 10 --merge-output-format "mp4" --sub-langs "en-US.*,zh-Hans.*" --convert-thumbnails png --ffmpeg-location ..\\bin ${init?'>':'>>'} %25~dp0${collect||category}_ytb.cmd`);
3137
html.push(`<!doctype html>`);
3238
html.push(`<html lang="en-US">`)
3339
html.push(`<head>`)
@@ -48,13 +54,13 @@ function getCategoryInfo(cmd, collect, init){
4854
html.push(`<script>`);
4955
html.push(`function viewVideo(evt,url){ var img=new Image(); img.onerror=function(){window.open(url.replace("video.mp4","index.html"))};img.onload=function(){window.open(url)};img.src=url.replace(".mp4",".png");}`);
5056
html.push(`</script></head><body>`);
51-
commands.push(`@echo ${proxy||'.'} > "%25~dp0\\assets\\proxy.conf"`);
52-
commands.push(`@echo @echo tutorial resource downloader ${init?'>':'>>'} %25~dp0\\${collect||category}_res.cmd`);
53-
commands.push(`@echo @title %25cd%25 >> %25~dp0\\${collect||category}_res.cmd`);
54-
commands.push(`@echo @title %25cd%25 >> %25~dp0\\${collect||category}_ytb.cmd`);
57+
commands.push(`@echo @echo resource downloader ${init?'>':'>>'} %25~dp0${collect||category}_res.cmd`);
58+
commands.push(`@echo @title %25cd%25 >> %25~dp0${collect||category}_res.cmd`);
59+
commands.push(`@echo @title %25cd%25 >> %25~dp0${collect||category}_ytb.cmd`);
5560
}
56-
commands.push(`@if not exist ${category} mkdir ${category}`);
57-
commands.push(`@cd ${category}`);
61+
commands.push(`@cd %25~dp0`);
62+
commands.push(`@if not exist %25~dp0${category} mkdir %25~dp0${category}`);
63+
commands.push(`@cd %25~dp0${category}`);
5864
let items = document.querySelectorAll('.tutorialsBrowser__mainCategoryList >.tutorialsBrowser__mainItem');
5965
items.forEach((item,index)=>{
6066
let img = item.querySelector('.tutorialsThumbnail__image');
@@ -87,7 +93,6 @@ function getCategoryInfo(cmd, collect, init){
8793
commands.push(`@rem downloading ${encodeURI(x2.join('/').split(' ')[0])}`);
8894
commands.push(`@if not exist "${img2}" @curl -o "${img2}" "${url2}" 2>NUL`);
8995
commands.push(`@%25getpage%25 "${lnk}" "${category}\\${pth}" "${collect||category}"`);
90-
commands.push(`@cd %25~dp0`);
9196
});
9297
if(items.length>0){
9398
html.push(`</div>`);
@@ -104,13 +109,18 @@ function getCategoryInfo(cmd, collect, init){
104109
function getGuideCmd(){
105110
let guides = document.querySelectorAll('.guides-menu a');
106111
let cmds = [];
107-
cmds.push('cls');
108-
cmds.push('@set getpage=%25~dp0\\..\\getpage.exe');
109-
cmds.push(`@if not exist %25~dp0guide mkdir %25~dp0guide`);
110112
let lproxy = localStorage.getItem('pixelmatorTutorialDownloader_proxy');
111113
proxy = prompt("Input proxy string like http://127.0.0.1:8899, if no proxy keep it empty", lproxy || '');
112114
localStorage.setItem('pixelmatorTutorialDownloader_proxy', proxy||'');
113-
cmds.push(`@echo ${proxy||'.'} > "%25~dp0\\assets\\proxy.conf"`);
115+
cmds.push(`cls`);
116+
cmds.push(`@set proxy=`);
117+
cmds.push(`@set proxy=${proxy}`);
118+
cmds.push(`@set pxystr=`)
119+
cmds.push(`@if "%25proxy%25" == "" @echo.>"%25~dp0assets\\proxy.conf"`);
120+
cmds.push(`@if not "%25proxy%25" == "" @echo %25proxy%25>"%25~dp0assets\\proxy.conf"`);
121+
cmds.push(`@if not "%25proxy%25" == "" @set pxystr=--proxy "%25proxy%25"`);
122+
cmds.push(`@set getpage=%25~dp0..\\bin\\getpage.exe`);
123+
cmds.push(`@if not exist %25~dp0guide mkdir %25~dp0guide`);
114124
for(let i=0,il=guides.length; i<il; i++){
115125
let guide = guides[i];
116126
let match = guide.getAttribute('href').match(/\/pixelmator-pro\/(\d+)/)

0 commit comments

Comments
 (0)