GETID3 on network shares

The place for "I can't figure out how to..." questions.
Post Reply
shawn_collins24
User
Posts: 10
Joined: Tue Jul 09, 2013 5:55 am
Are you a spambot?: no

GETID3 on network shares

Post by shawn_collins24 » Tue Jul 09, 2013 6:22 am

I've searched the forums and the internet and can not find a solution. The problem is, I haven't found much to address my question, which makes me believe I'm not searching for the correct terms. Here's what I've learned from the forums and here's what I'm trying to do:

* I realize the GETID3 doesn't work on remote files (without modifying the code)
* I want to analyze files on a local network share (i.e. my MP3s are on a server, but I'm messing around with PHP/MySQL/GetID3 on another machine)
* The MP3 directories and files parse/are read correctly when copied to the local machine
* When attempted on a network share, the MP3s on the network share do NOT parse correctly, but the directories themselves are parse
* After going through all the directories -which are organized by artist, not that it matters- it sees each MP3 file, but each file gets an "Unknown File Type"
* I've tried accessing the network share in the following manners:
- \\networkshare\music
- m:\music (mapped drive letter)

Both methods actually SEE the files correctly, but I get the "Unknown File Type" error as mentioned above as it attempts to parse each file.

This problem also exists when the music files are local and I attempt to parse them from within a virtual machine (which, of course, causes them also to be "shared network files" and not treated as local files).

Is there something I'm doing wrong or is GETID3 limited to local files only? If there's a workaround, can someone help me? As a geek (university student, senior, Computer Management Information Systems), if there isn't a workaround, could you take a minute and explain to me WHY it doesn't work? I see no reason why it doesn't parse correctly when a drive letter is mapped to the network share.

Here's a partial parse if visualization helps at all:

M:/Music/Wynonna
M:/Music/Yellowman
M:/Music/Young MC
M:/Music/Zapp
<truncated>
08:14:33 [1 / 5,117] M:/Music/3 Doors Down/3 Doors Down - Kryptonite.mp3 (unknown file type)
08:14:33 [2 / 5,117] M:/Music/40 Below Summer/40 Below Summer - We the People.mp3 (unknown file type)
08:14:33 [3 / 5,117] M:/Music/4Him/4Him - Before the River Came.mp3 (unknown file type)
08:14:33 [4 / 5,117] M:/Music/4Him/4Him - Can't Get Past the Evidence.mp3 (unknown file type)
08:14:33 [5 / 5,117] M:/Music/4Him/4Him - Center of the Mark.mp3 (unknown file type)

Thanks for any help!

Shawn Collins

James Heinrich
getID3() v1 developer
Posts: 1424
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: GETID3 on network shares

Post by James Heinrich » Tue Jul 09, 2013 1:13 pm

Hi Shawn,

Sounds like a permissions issue. I'm not sure what webserver you're using, but assuming Apache on Windows you'd need to change the service properties from starting as the "Local System account" to a user account that has network access permissions:
apache-user.png
apache-user.png (22.12 KiB) Viewed 28623 times
Quick test:

Code: Select all

var_dump(opendir('\\\\networkshare\\Music'));
if that gives you "resource(11) of type (stream)" then you're able to access the network.

Once you get PHP able to see across the network then getID3 shouldn't have any problems.

Final question: Are you (now) able to browse the network shared files using demo/demo.browse.php ? If demo.browse works but you're still having trouble with your code, please post the section of your code that is reading the mapped network drive.

shawn_collins24
User
Posts: 10
Joined: Tue Jul 09, 2013 5:55 am
Are you a spambot?: no

Re: GETID3 on network shares

Post by shawn_collins24 » Wed Jul 10, 2013 11:57 am

I'm writing this in the few minutes I have before I have to get ready for school (summer classes), but here's the additional info I can give for now:

* The code I'm using is the stock "demo.mysql.php"
* I'm running Windows 7 Professional on my "development machine"
* I'm running under an Administrative account (but not the (by default disabled) "Administrator" account)
* I'm running Apache under Windows
* I can browse the network shares with "demo.browse.php" without having made any changes, but when it reads/attempts to read the files, I get an "Unknown File Type" error. It "sees" all the directories AND "sees" all the files, but I get the unknown file type.
* I'm using XAMPP (newest). I am still learning :)
* Apache does not appear as a "service" even though it is currently running, BUT I manually start up Apache and MySQL when I want to "develop". After school today, I will reconfigure Apache and MySQL to start with Windows and change the Apache account to one with network permissions. Running on the Administrative account, however, is this necessary? Since I'm manually starting Apache and MySQL, wouldn't it have the same administrative permissions that I do?

*** Something I think is worth repeating is that without invoking any of the suggested changes yet -'cuz I have school this morning- I can browse the directories and see the files just fine with "demo.browse.php". It just doesn't recognize them ("Unknown File Type") over the network. Copying them locally and scanning them works fine, so that eliminates a problem with the .mp3s themselves. Here's a "demo.browse.php" screen shot over the mapped drive. The error on the screen is what pops up when I click on the "error" link after a file:
DemoBrowseScreenshot.jpg
DemoBrowseScreenshot.jpg (65.49 KiB) Viewed 28599 times
If I'm missing something incredibly simple, I SERIOUSLY apologize. I'm reading as much about this and learning as much as I can. What you said about the service needing "network access permissions" makes sense, except I would think the service -running under my administrative account- would already have the necessary permissions.

Thank you for your response earlier! BTW,

Shawn

James Heinrich
getID3() v1 developer
Posts: 1424
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: GETID3 on network shares

Post by James Heinrich » Wed Jul 10, 2013 12:29 pm

If you're manually running Apache then that's fine, it will share your permissions. It's only if it's running as a service that it would, by default, run under the SYSTEM account.

The error message your screenshot shows means this line (line 265 in getid3.php) is failing:

Code: Select all

if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) {
However, one odd thing I notice from your error message is that the directory slashes appear to have disappeared. It's possible that this is just an artifact from the Javascript popping up the error message, but obviously if it's trying to open "M:MusicUncle KrackerUncleKracker - Drift Away.mp3" rather than "M:/Music/Uncle Kracker/UncleKracker - Drift Away.mp3" it wouldn't work.

The code getting to the point where the directory is listed is working fine, since you can see the list of files. However the filenames in each directory don't seem to be behaving as expected. Running this might provide some insight as to what filenames are being generated by the code demo.browse uses:

Code: Select all

$listdirectory = 'M:/Music/Uncle Kracker';
if ($handle = opendir($listdirectory)) {
	while ($file = readdir($handle)) {
		$currentfilename = $listdirectory.'/'.$file;
echo $currentfilename.'<br>';
	}
}

shawn_collins24
User
Posts: 10
Joined: Tue Jul 09, 2013 5:55 am
Are you a spambot?: no

Re: GETID3 on network shares

Post by shawn_collins24 » Wed Jul 10, 2013 6:14 pm

Here's the screenshot that resulted from adding that code snippet you provided:
DemoBrowseScreenshot.jpg
DemoBrowseScreenshot.jpg (64.17 KiB) Viewed 28588 times
So the missing slash isn't the problem. Here's the kicker: After thinking about this further -I haven't played with this since summer semester started- I am VERY SURE that this worked with a previous version of GETID3. So, to do my part to help out, I verified this. Here's a screenshot of what happens when I used "Last version for PHP v4.x: v1.7.10 (released 26-Apr-2009)":
DemoBrowseScreenshotSuccessOldVersion.jpg
DemoBrowseScreenshotSuccessOldVersion.jpg (40.9 KiB) Viewed 28588 times
So the old version works as intended, but the new version doesn't. Just to try to provide you with as much information as possible, I posted some info for you below. I believe, since I discovered a bug, that I should be rewarded with a free version of getid3. :) Oh, wait...uh...nevermind. :)

If there's anything at all I can do to help track down this problem, please let me know!

Code: Select all

Compiler	MSVC9 (Visual C++ 2008)
Architecture	x86
Configure Command	cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo"
Server API	Apache 2.0 Handler
Virtual Directory Support	enabled
Configuration File (php.ini) Path	C:\Windows
Loaded Configuration File	C:\xampp\php\php.ini
Scan this dir for additional .ini files	(none)
Additional .ini files parsed	(none)
PHP API	20100412
PHP Extension	20100525
Zend Extension	220100525
Zend Extension Build	API220100525,TS,VC9
PHP Extension Build	API20100525,TS,VC9
Debug Build	no
Thread Safety	enabled
Zend Signal Handling	disabled
Zend Memory Manager	enabled
Zend Multibyte Support	provided by mbstring
IPv6 Support	enabled
DTrace Support	disabled
Registered PHP Streams	php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar
Registered Stream Socket Transports	tcp, udp, ssl, sslv3, sslv2, tls
Registered Stream Filters	convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, zlib.*, bzip2.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

PHP Credits

Configuration

apache2handler

Apache Version	Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.16
Apache API Version	20120211
Server Administrator	postmaster@localhost
Hostname:Port	localhost:80
Max Requests	Per Child: 0 - Keep Alive: on - Max Per Connection: 100
Timeouts	Connection: 300 - Keep-Alive: 5
Virtual Server	No
Server Root	C:/xampp/apache
Loaded Modules	core mod_win32 mpm_winnt http_core mod_so mod_access_compat mod_actions mod_alias mod_allowmethods mod_asis mod_auth_basic mod_authn_core mod_authn_file mod_authz_core mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dav_lock mod_dir mod_env mod_headers mod_include mod_info mod_isapi mod_log_config mod_cache_disk mod_mime mod_negotiation mod_proxy mod_proxy_ajp mod_rewrite mod_setenvif mod_socache_shmcb mod_ssl mod_status mod_version mod_php5

Directive	Local Value	Master Value
engine	1	1
last_modified	0	0
xbithack	0	0

Apache Environment

Variable	Value
MIBDIRS	C:/xampp/php/extras/mibs
MYSQL_HOME	\xampp\mysql\bin
OPENSSL_CONF	C:/xampp/apache/bin/openssl.cnf
PHP_PEAR_SYSCONF_DIR	\xampp\php
PHPRC	\xampp\php
TMP	\xampp\tmp
HTTP_HOST	localhost
HTTP_CONNECTION	keep-alive
HTTP_ACCEPT	text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENT	Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36
HTTP_REFERER	http://localhost/xampp/navi.php
HTTP_ACCEPT_ENCODING	gzip,deflate,sdch
HTTP_ACCEPT_LANGUAGE	en-US,en;q=0.8
PATH	C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\PHP\
SystemRoot	C:\Windows
COMSPEC	C:\Windows\system32\cmd.exe
PATHEXT	.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
WINDIR	C:\Windows
SERVER_SIGNATURE	<address>Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.16 Server at localhost Port 80</address>
SERVER_SOFTWARE	Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.16
SERVER_NAME	localhost
SERVER_ADDR	::1
SERVER_PORT	80
REMOTE_ADDR	::1
DOCUMENT_ROOT	C:/xampp/htdocs
REQUEST_SCHEME	http
CONTEXT_PREFIX	no value
CONTEXT_DOCUMENT_ROOT	C:/xampp/htdocs
SERVER_ADMIN	postmaster@localhost
SCRIPT_FILENAME	C:/xampp/htdocs/xampp/phpinfo.php
REMOTE_PORT	50643
REMOTE_USER	shawn
AUTH_TYPE	Basic
GATEWAY_INTERFACE	CGI/1.1
SERVER_PROTOCOL	HTTP/1.1
REQUEST_METHOD	GET
QUERY_STRING	no value
REQUEST_URI	/xampp/phpinfo.php
SCRIPT_NAME	/xampp/phpinfo.php

James Heinrich
getID3() v1 developer
Posts: 1424
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: GETID3 on network shares

Post by James Heinrich » Wed Jul 10, 2013 6:26 pm

Let's at least see which check is failing:

Code: Select all

// fixed code, see few posts below
$filename = 'M:/Music/Uncle Kracker/UncleKracker - Drift Away.mp3';
echo 'is_readable('.$filename.') = '.(is_readable($filename) ? 'true' : 'false').'<br>';
echo 'is_file('.$filename.') = '.(is_file($filename) ? 'true' : 'false').'<br>';
echo 'fopen('.$filename.', rb) = '.(fopen($filename, 'rb') ? 'true' : 'false').'<br>';
shawn_collins24 wrote:I believe, since I discovered a bug, that I should be rewarded with a free version of getid3. :)
Free versions of getID3 are awarded to those who find bugs and their cause and provide a patch to fix it ;)

shawn_collins24
User
Posts: 10
Joined: Tue Jul 09, 2013 5:55 am
Are you a spambot?: no

Re: GETID3 on network shares

Post by shawn_collins24 » Wed Jul 10, 2013 6:46 pm

I pasted the code in and get an error. I pasted twice, and I'm not yet knowledgeable enough to figure out what's missing:

Parse error: syntax error, unexpected ')', expecting ',' or ';' in C:\xampp\htdocs\getid3\getid3\getid3.php on line 267

Line 267 is:
echo 'is_readable('.$filename).' = '.(is_readable($filename) ? 'true' : 'false').'<br>';

My editor could be off by a line number. I looked through the 3 lines it could be and see nothing missing, but again, I don't see what's missing.

Shawn

shawn_collins24
User
Posts: 10
Joined: Tue Jul 09, 2013 5:55 am
Are you a spambot?: no

Re: GETID3 on network shares parse error

Post by shawn_collins24 » Wed Jul 10, 2013 6:52 pm

Actually, I get that error on all 3 lines when commenting out the other two for testing purposes. I'm guessing I could be pasting them in the wrong place, but they're just echo statements. It shouldn't matter. Here's where I'm pasting them in get.id3.php:
CodeSnippetError.jpg
CodeSnippetError.jpg (87.98 KiB) Viewed 28585 times
Shawn

James Heinrich
getID3() v1 developer
Posts: 1424
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: GETID3 on network shares

Post by James Heinrich » Wed Jul 10, 2013 7:10 pm

These test snippets don't matter where they go, they can be in a standalone file, or even in an interactive frontend to eval like this:
http://www.silisoftware.com/scripts/phpEval
(great as a development tool, just don't ever put such a thing on a public-accessible site)

Anyhow, moving the ) to where it should be:

Code: Select all

$filename = 'M:/Music/Uncle Kracker/UncleKracker - Drift Away.mp3';
echo 'is_readable('.$filename.') = '.(is_readable($filename) ? 'true' : 'false').'<br>';
echo 'is_file('.$filename.') = '.(is_file($filename) ? 'true' : 'false').'<br>';
echo 'fopen('.$filename.', rb) = '.(fopen($filename, 'rb') ? 'true' : 'false').'<br>';

shawn_collins24
User
Posts: 10
Joined: Tue Jul 09, 2013 5:55 am
Are you a spambot?: no

Re: GETID3 on network shares

Post by shawn_collins24 » Wed Jul 10, 2013 9:17 pm

Here's the results of me pasting the new code snippet:

Warning: fopen() expects at least 2 parameters, 1 given in C:\xampp\htdocs\getid3\getid3\getid3.php on line 269
fopen(M:/Music/Uncle Kracker/Uncle Kracker - Drift Away.mp3) = false
.is_readable(M:/Music/Uncle Kracker/Uncle Kracker - Drift Away.mp3) = false
is_file(M:/Music/Uncle Kracker/Uncle Kracker - Drift Away.mp3) = true

For your convenience, the entire fopen() line is here:
echo 'fopen('.$filename.') = '.(fopen($filename) ? 'true' : 'false').'<br>';

I'd like to mention that your code snippet is missing a <space> between the 2nd "Uncle Kracker" (the artist before the song), but I added it before having the code execute.

James Heinrich
getID3() v1 developer
Posts: 1424
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: GETID3 on network shares

Post by James Heinrich » Wed Jul 10, 2013 9:25 pm

That's what I get for posting untested code snippets (twice!)

Code: Select all

echo 'fopen('.$filename.', rb) = '.(fopen($filename, 'rb') ? 'true' : 'false').'<br>';
But in any case, we see is_readable failing when it shouldn't, even though is_file succeeds. What about file_exists?

Code: Select all

echo 'file_exists('.$filename.') = '.(file_exists($filename) ? 'true' : 'false').'<br>';
And what about bypassing the mapped drive and accessing the network share name directly?

Code: Select all

//$filename = 'M:/Music/Uncle Kracker/Uncle Kracker - Drift Away.mp3';
$filename = '\\\\networkshare\\Music\\Uncle Kracker\\Uncle Kracker - Drift Away.mp3';
echo 'is_readable('.$filename.') = '.(is_readable($filename) ? 'true' : 'false').'<br>';
echo 'is_file('.$filename.') = '.(is_file($filename) ? 'true' : 'false').'<br>';
echo 'fopen('.$filename.', rb) = '.(fopen($filename, 'rb') ? 'true' : 'false').'<br>';
echo 'file_exists('.$filename.') = '.(file_exists($filename) ? 'true' : 'false').'<br>';

shawn_collins24
User
Posts: 10
Joined: Tue Jul 09, 2013 5:55 am
Are you a spambot?: no

Re: GETID3 on network shares

Post by shawn_collins24 » Wed Jul 10, 2013 9:50 pm

Original (fixed) test snippet with file_exists added results in this:

Warning: fopen() expects at least 2 parameters, 1 given in C:\xampp\htdocs\getid3\getid3\getid3.php on line 269
fopen(M:/Music/Uncle Kracker/Uncle Kracker - Drift Away.mp3) = false
file_exists(M:/Music/Uncle Kracker/Uncle Kracker - Drift Away.mp3) = true
.is_readable(M:/Music/Uncle Kracker/Uncle Kracker - Drift Away.mp3) = false
is_file(M:/Music/Uncle Kracker/Uncle Kracker - Drift Away.mp3) = true


Bypassing the mapped drive and accessing the network share name directly results in this (which is the same results for your boolean test):
Warning: fopen() expects at least 2 parameters, 1 given in C:\xampp\htdocs\getid3\getid3\getid3.php on line 270
fopen(\\Cloud\Music\Uncle Kracker\Uncle Kracker - Drift Away.mp3) = false
file_exists(\\Cloud\Music\Uncle Kracker\Uncle Kracker - Drift Away.mp3) = true
.is_readable(\\Cloud\Music\Uncle Kracker\Uncle Kracker - Drift Away.mp3) = false
is_file(\\Cloud\Music\Uncle Kracker\Uncle Kracker - Drift Away.mp3) = true

shawn_collins24
User
Posts: 10
Joined: Tue Jul 09, 2013 5:55 am
Are you a spambot?: no

GETID3 on network shares ADDENDUM

Post by shawn_collins24 » Wed Jul 10, 2013 10:04 pm

I changed one of your code snippet lines to this:

echo 'fopen('.$filename.') = '.(fopen($filename, rb) ? 'true' : 'false').'<br>';

and now fopen = true. Note the "rb parameter" I added to the "(fopen($filename, rb)" command. Here's the results pasted:

Notice: Use of undefined constant rb - assumed 'rb' in C:\xampp\htdocs\getid3\getid3\getid3.php on line 270
fopen(\\Cloud\Music\Uncle Kracker\Uncle Kracker - Drift Away.mp3) = true
file_exists(\\Cloud\Music\Uncle Kracker\Uncle Kracker - Drift Away.mp3) = true
.is_readable(\\Cloud\Music\Uncle Kracker\Uncle Kracker - Drift Away.mp3) = false
is_file(\\Cloud\Music\Uncle Kracker\Uncle Kracker - Drift Away.mp3) = true

Since the file now opens, I don't understand why it isn't readable (but I'm trying to figure that out by reading until you post your next suggestion).

shawn_collins24
User
Posts: 10
Joined: Tue Jul 09, 2013 5:55 am
Are you a spambot?: no

Undefined constant error fixed

Post by shawn_collins24 » Wed Jul 10, 2013 10:18 pm

I changed the code snippet to enclose the rb parameter in quotes (which, of course, eliminated the "undefined constant" error noted above. The snippet now reads:

echo 'fopen('.$filename.') = '.(fopen($filename, 'rb') ? 'true' : 'false').'<br>';

.is_readable still returns false, however. :(

James Heinrich
getID3() v1 developer
Posts: 1424
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: GETID3 on network shares

Post by James Heinrich » Wed Jul 10, 2013 10:27 pm

So, for whatever reason, is_readable doesn't like your server / network configuration. Not sure how or why.

You could try taking out the is_readable part of line 265 of getid3.php and that will probably fix your problem. Perhaps change it to file_exists since that seems to work:

Code: Select all

//if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) {
if (file_exists($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) {

shawn_collins24
User
Posts: 10
Joined: Tue Jul 09, 2013 5:55 am
Are you a spambot?: no

Re: GETID3 on network shares

Post by shawn_collins24 » Wed Jul 10, 2013 10:42 pm

Did you notice, however, that to get fopen to return true in your code snippet, I had to add the "rb" parameters to it?
That's because I'm apparently not very good at copy-pasting my code snippets :(
I've edited all the above instances (in my posts) to have the correct mode string ('rb' = read, binary) that I kept forgetting as I copy-pasted examples.

I'll probably change is_readable to file_exists for the next version, or actually probably a compromise that will accept one of them in case some other unusual server configuration breaks the other way.

Code: Select all

if ((is_readable($filename) || file_exists($filename)) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) {

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest