Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
29291a9d
Commit
29291a9d
authored
Mar 27, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eget: add support for URL in form file:/ or /path
parent
128275aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
7 deletions
+62
-7
tools_eget
bin/tools_eget
+62
-7
No files found.
bin/tools_eget
View file @
29291a9d
...
...
@@ -160,6 +160,25 @@ filter_order()
sort
-V
|
tail
-n1
}
is_fileurl
()
{
echo
"
$1
"
|
grep
-q
"^/"
&&
return
echo
"
$1
"
|
grep
-q
"file:/"
}
dir_from_url
()
{
echo
"
$1
"
|
sed
-e
's|^file://*|/|'
}
is_url
()
{
echo
"
$1
"
|
grep
-q
":/"
}
# args: cmd <URL> <options>
# will run cmd <options> <URL>
download_with_mirroring
()
...
...
@@ -232,7 +251,35 @@ fi
WGET
=
"
$(
which wget 2>/dev/null
)
"
if
[
-n
"
$WGET
"
]
;
then
if
is_fileurl
"
$1
"
;
then
# put remote content to stdout
scat
()
{
local
URL
=
"
$1
"
cat
"
$(
dir_from_url
"
$URL
"
)
"
}
# download to default name of to $2
sget
()
{
local
URL
=
"
$1
"
if
[
"
$2
"
=
"/dev/stdout"
]
||
[
"
$2
"
=
"-"
]
;
then
scat
"
$URL
"
return
elif
[
-n
"
$2
"
]
;
then
cp
-av
"
$(
dir_from_url
"
$URL
"
)
"
"
$2
"
return
fi
cp
-av
"
$(
dir_from_url
"
$URL
"
)
"
.
}
check_url_is_accessible
()
{
local
URL
=
"
$1
"
test
-f
"
$(
dir_from_url
"
$URL
"
)
"
}
elif
[
-n
"
$WGET
"
]
;
then
__wget
()
{
if
[
-n
"
$WGETUSERAGENT
"
]
;
then
...
...
@@ -411,15 +458,14 @@ fi
# If have no wildcard symbol like asterisk, just download
if
echo
"
$MASK
"
|
grep
-qv
"[*?]"
||
echo
"
$MASK
"
|
grep
-q
"[?].*="
;
then
if
is_fileurl
"
$1
"
;
then
cp
-v
"
$(
dir_from_url
)
"
"
$TARGEFILE
"
exit
fi
sget
"
$1
"
"
$TARGETFILE
"
exit
fi
is_url
()
{
echo
"
$1
"
|
grep
-q
"://"
}
# drop file path from URL
get_host_only
()
{
...
...
@@ -432,6 +478,10 @@ make_fileurl()
local
url
=
"
$1
"
local
fn
=
"
$2
"
fn
=
"
$(
echo
"
$fn
"
|
sed
-e
's|^./||'
-e
's|^/+||'
)
"
if
is_fileurl
"
$url
"
;
then
echo
"
$url
/
$fn
"
return
fi
# if there is file path from the root of the site
if
echo
"
$fn
"
|
grep
-q
"^/"
;
then
echo
"
$(
get_host_only
"
$url
"
)
$fn
"
...
...
@@ -443,6 +493,11 @@ make_fileurl()
get_urls
()
{
if
is_fileurl
"
$URL
"
;
then
ls
-1
"
$(
dir_from_url
"
$URL
"
)
"
return
fi
# cat html, divide to lines by tags and cut off hrefs only
scat
$URL
|
sed
-e
's|<|<\n|g'
-e
's|data-file=|href=|g'
|
\
grep
-i
-o
-E
'href="(.+)"'
|
cut
-d
'"'
-f2
...
...
@@ -450,7 +505,7 @@ get_urls()
if
[
-n
"
$LISTONLY
"
]
;
then
for
fn
in
$(
get_urls | filter_glob
"
$MASK
"
| filter_order
)
;
do
is_url
"
$fn
"
&&
echo
$fn
&&
continue
is_url
"
$fn
"
&&
echo
"
$fn
"
&&
continue
make_fileurl
"
$URL
"
"
$fn
"
done
exit
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment