Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remote urls pattern #369

Merged
merged 2 commits into from
Oct 27, 2022
Merged

Fix remote urls pattern #369

merged 2 commits into from
Oct 27, 2022

Conversation

vgpastor
Copy link

Add secure urls to expression

@JamesHeinrich
Copy link
Owner

It does need fixing but your suggested change would not accept both secure/nonsecure URLs. It should be:
^(ht|f)tps?://
Can you please update your PR?

@vgpastor
Copy link
Author

Hi @JamesHeinrich sorry, i write more faster than my mind.

I add test to prevent the future errors.

I think in make a method to download locally elements and analyze in temporaly storage and delete in the end. You like? I can put this in a new PR.

You have any board or list with the features or things to do?

What it's the older PHP version supported in version 2?

Regards!

@StudioMaX
Copy link
Collaborator

StudioMaX commented Feb 22, 2022

Bugfixes should go to the master branch, which is currently our main branch. Then I periodically merge commits from the master to 2.0.
As you can see, we don't have tests at all. And adding a test in your case, although good, does not actually change anything.

I think in make a method to download locally elements and analyze in temporaly storage and delete in the end. You like? I can put this in a new PR.

Downloading files from external sources is not specifically supported, getID3 only works with local files. So it is the user's responsibility to download the file to a local storage for further analysis.

getID3/readme.txt

Lines 174 to 206 in 81cf18e

To analyze remote files over HTTP or FTP you need to copy the file
locally first before running getID3(). Your code would look something
like this:
// Copy remote file locally to scan with getID3()
$remotefilename = 'http://www.example.com/filename.mp3';
if ($fp_remote = fopen($remotefilename, 'rb')) {
$localtempfilename = tempnam('/tmp', 'getID3');
if ($fp_local = fopen($localtempfilename, 'wb')) {
while ($buffer = fread($fp_remote, 32768)) {
fwrite($fp_local, $buffer);
}
fclose($fp_local);
$remote_headers = array_change_key_case(get_headers($remotefilename, 1), CASE_LOWER);
$remote_filesize = (isset($remote_headers['content-length']) ? (is_array($remote_headers['content-length']) ? $remote_headers['content-length'][count($remote_headers['content-length']) - 1] : $remote_headers['content-length']) : null);
// Initialize getID3 engine
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($localtempfilename, $remote_filesize, basename($remotefilename));
// Delete temporary file
unlink($localtempfilename);
}
fclose($fp_remote);
}
Note: since v1.9.9-20150212 it is possible a second and third parameter
to $getID3->analyze(), for original filesize and original filename
respectively. This permits you to download only a portion of a large remote
file but get accurate playtime estimates, assuming the format only requires
the beginning of the file for correct format analysis.

What it's the older PHP version supported in version 2?

Now the technically minimum supported version for GetID3 2.x is PHP 5.4 (as specified in composer.json). The plans are to bump this version to ^7.2 after I add the type declaration.

JamesHeinrich added a commit that referenced this pull request Feb 22, 2022
@StudioMaX StudioMaX added the 2.x Issues related to GetID3 2.x label Oct 27, 2022
@JamesHeinrich JamesHeinrich merged commit b19ed0e into JamesHeinrich:2.0 Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Issues related to GetID3 2.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants