Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
eget
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
Ivan Ivlev
eget
Commits
d98bd347
Commit
d98bd347
authored
Oct 23, 2020
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eget: add support for
https://github.com/owner/project
urls
parent
6a39e446
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
4 deletions
+38
-4
eget
eget
+38
-4
No files found.
eget
View file @
d98bd347
...
...
@@ -3,9 +3,9 @@
# Example use:
# eget http://ftp.altlinux.ru/pub/security/ssl/*
#
# Copyright (C) 2014-2014, 2016 Etersoft
# Copyright (C) 2014-2014, 2016
, 2020
Etersoft
# Copyright (C) 2014 Daniil Mikhailov <danil@etersoft.ru>
# Copyright (C) 2016-2017 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2016-2017
, 2020
Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
...
...
@@ -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,13 +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
echo
"eget supports --list and download for https://github.com/owner/project urls"
echo
wget
--help
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