Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Citronalco
FM4-7Tage-Download
Commits
7e8f9757
Commit
7e8f9757
authored
Nov 18, 2017
by
Bernhard Geier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try to fix incomplete downloads. again.
parent
6040dda2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
8 deletions
+26
-8
fm4-7tage-download.pl
fm4-7tage-download.pl
+26
-8
No files found.
fm4-7tage-download.pl
View file @
7e8f9757
...
...
@@ -50,23 +50,41 @@ foreach (@{$result->{'hits'}}) {
my
$filename
=
"
FM4
"
.
$tagTitle
.
"
.mp3
";
$filename
=~
s/[^\w\s\-\.\[\]]/_/g
;
if
(
-
f
$DESTDIR
.
"
/
"
.
$filename
)
{
print
$filename
.
"
already exists, skipping.
\n
";
next
;
}
print
$filename
.
"
downloading...
";
my
$try
=
5
;
do
{
$browser
->
get
(
$shoutcastBaseUrl
.
$parts
[
$i
]
->
{'
loopStreamId
'});
}
while
(
--
$try
>
0
and
!
$browser
->
success
());
if
(
$try
==
0
)
{
my
(
$tries
,
@parameters
,
$FD
);
$tries
=
4
;
@parameters
=
(
$shoutcastBaseUrl
.
$parts
[
$i
]
->
{'
loopStreamId
'},
# URL
"
:content_cb
"
=>
sub
{
my
(
$chunk
)
=
@_
;
print
$FD
$chunk
;
});
while
(
$tries
)
{
open
(
$FD
,"
>>
"
.
$DESTDIR
.
"
/
"
.
$filename
.
"
.part
");
my
$bytes
=-
s $DESTDIR."/".$filename.".part";
if ($
bytes
>
0
)
{
push
(
@parameters
,"
Range
"
=>
"
bytes=
"
.
$bytes
.
"
-
");
}
my
$result
=
$browser
->
get
(
@parameters
);
close
$FD
;
last
if
(
$result
->
is_success
or
$result
->
code
==
416
);
$tries
--
;
}
if
(
$tries
eq
0
)
{
print
"
failed.
\n
";
next
;
}
$browser
->
save_content
(
$DESTDIR
.
"
/
"
.
$filename
)
;
rename
$DESTDIR
.
"
/
"
.
$filename
.
"
.part
",
$DESTDIR
.
"
/
"
.
$filename
;
my
$tag
=
MP3::
Tag
->
new
(
$DESTDIR
.
"
/
"
.
$filename
);
$tag
->
get_tags
;
$tag
->
new_tag
("
ID3v2
")
unless
(
exists
$tag
->
{
ID3v2
});
...
...
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