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
Vladislav
eepm
Commits
d5d6a57d
Commit
d5d6a57d
authored
Oct 23, 2020
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools_eget: add support for
https://github.com/owner/project
urls
parent
489efac7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
2 deletions
+35
-2
tools_eget
bin/tools_eget
+35
-2
No files found.
bin/tools_eget
View file @
d5d6a57d
...
...
@@ -50,6 +50,7 @@ fatal()
# check man glob
filter_glob
()
{
[
-z
"
$1
"
]
&&
cat
&&
return
# translate glob to regexp
grep
"^
$(
echo
"
$1
"
|
sed
-e
"s|
\*
|.*|g"
-e
"s|?|.|g"
)
$"
}
...
...
@@ -79,14 +80,46 @@ fi
if
[
"
$1
"
=
"-h"
]
||
[
"
$1
"
=
"--help"
]
;
then
echo
"eget - wget wrapper, with support"
echo
"Usage: eget [-O target file] [--list] http://somesite.ru/dir/na*.log"
echo
echo
"Options:"
echo
" --list - print files frm url with mask"
echo
" --list
- print files frm url with mask"
echo
" --latest - print only latest version of file"
echo
wget
--help
echo
"eget supports --list and download for https://github.com/owner/project urls"
echo
echo
"See
$
wget --help for wget options you can use here"
exit
fi
get_github_urls
()
{
# https://github.com/OWNER/PROJECT
local
owner
=
"
$(
echo
"
$1
"
|
sed
-e
"s|^https://github.com/||"
-e
"s|/.*||"
)
"
#"
local
project
=
"
$(
echo
"
$1
"
|
sed
-e
"s|^https://github.com/
$owner
/||"
-e
"s|/.*||"
)
"
#"
[
-n
"
$owner
"
]
||
fatal
"Can't get owner from
$1
"
[
-n
"
$project
"
]
||
fatal
"Can't get project from
$1
"
local
URL
=
"https://api.github.com/repos/
$owner
/
$project
/releases/latest"
local
q
=
''
[
-n
"
$LISTONLY
"
]
&&
q
=
"-q"
$WGET
$q
-O-
$URL
|
\
grep
-i
-o
-E
'"browser_download_url": "https://.*"'
|
cut
-d
'"'
-f4
}
if
echo
"
$1
"
|
grep
-q
"^https://github.com/"
;
then
MASK
=
"
$2
"
if
[
-n
"
$LISTONLY
"
]
;
then
get_github_urls
"
$1
"
| filter_glob
"
$MASK
"
| filter_order
exit
fi
for
fn
in
$(
get_github_urls
"
$1
"
| filter_glob
"
$MASK
"
| filter_order
)
;
do
$WGET
"
$fn
"
||
ERROR
=
1
done
exit
fi
# do not support /
if
echo
"
$1
"
|
grep
-q
"/$"
;
then
fatal
"Use http://example.com/e/* to download all files in dir"
...
...
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