ArturSierzant / OMPD

O!MPD is free, opensource MPD client based on PHP and mySQL.
http://ompd.pl
GNU General Public License v3.0
40 stars 13 forks source link

Update fails, invalid year ? #157

Closed tomchiverton closed 1 year ago

tomchiverton commented 2 years ago

Update time: | Update error! PHP Fatal ErrorUncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '??0, dr = NULL, composer ...' at line 29 in /home/ompd/update.php:1351 Stack trace: #0 /home/ompd/update.php(1351): mysqli_query(Object(mysqli), 'UPDATE track SE...') #1 /home/ompd/update.php(1222): fileInfo(Array, Object(getID3)) #2 /home/ompd/update.php(401): fileInfoLoop('') #3 /home/ompd/update.php(78): update('/exports/mp3/') #4 {main} thrown File: /home/ompd/update.php Line: 1351 \

ArturSierzant commented 2 years ago

Yes, it looks like problem with parsing the YEAR tag. Try to change $cfg['debug'] to true in include/config.inc.php and run update again. When it stops, open file \ompd\tmp\update_log.txt and at the end of it find at what track update crashed. Next open that file in tag editor you use and check value of YEAR tag (it can also be DATE, ORIGINALYEAR, ORIGYEAR, ORIGINALYEAR, ORIGINAL_YEAR, ORIGINAL_RELEASE_TIME or CREATION_DATE depending on file type). Then please let me know that value.

tomchiverton commented 2 years ago

Didn't seem to produce a log file :(

[root@bookcase ompd]# grep debug include/config.inc.php ; ls -laht tmp
//  | $cfg['debug'] - since O!MPD 1.01 this option set to true               |
$cfg['debug']                       = true;
$cfg['debug_memory']                = false;
total 108K
-rw-r--r--  1 apache apache  35K Jun 28 21:52 folder.jpg
-rw-r--r--  1 apache apache  59K Jun 28 21:52 folder.png
drwxr-xr-x 20 root   root   4.0K Jun 28 21:49 ..
drwxrwxr-x  2 root   root   4.0K Dec  3  2021 .
-rw-rw-r--  1 root   root     70 Dec  3  2021 .gitignore
[root@bookcase ompd]# 
tomchiverton commented 2 years ago

I hacked a simple fwrite into the cliLog function, and that worked.

The file in question logs this as the values

[root@bookcase ompd]# id3info  /exports/mp3/Albums/Mr.\ President\ -\ Coco\ Jamboo\:\ The\ Mixes/01\ -\ Mr.\ President\ -\ Coco\ Jamboo\ \(radio\ version\).mp3 

*** Tag information for /exports/mp3/Albums/Mr. President - Coco Jamboo: The Mixes/01 - Mr. President - Coco Jamboo (radio version).mp3
=== TSSE (Software/Hardware and settings used for encoding): LAME 64bits version 3.99.5 (http://lame.sf.net)
=== TIT2 (Title/songname/content description): Coco Jamboo (radio version)
=== TPE1 (Lead performer(s)/Soloist(s)): Mr. President
=== TALB (Album/Movie/Show title): Coco Jamboo: The Mixes
=== TYER (Year): 0
=== TLEN (Length): 220026
*** mp3 info
MPEG1/layer III
Bitrate: 128KBps
Frequency: 44KHz
[root@bookcase ompd]# 

kid3 (KDE tag editor) displays this field as red

Updating the tag works to continue indexing.

Maybe postProcessYear should strip non numeric as a fallback rather than returning input ?

tomchiverton commented 2 years ago

More details of whats up from id3v2...

# id3v2 -l  /exports/mp3/Albums/Mr.\ President\ -\ Coco\ Jamboo\:\ The\ Mixes/04\ -\ Mr.\ President\ -\ Coco\ Jamboo\ \(Drs\ Botanical\ 12\"\ mix\).mp3 
id3v1 tag info for /exports/mp3/Albums/Mr. President - Coco Jamboo: The Mixes/04 - Mr. President - Coco Jamboo (Drs Botanical 12" mix).mp3:
Title  : Coco Jamboo (Drs Botanical 12"  Artist: Mr. President                 
Album  : Coco Jamboo: The Mixes          Year:     , Genre: Unknown (255)
Comment:                                 Track: 0
id3v2 tag info for /exports/mp3/Albums/Mr. President - Coco Jamboo: The Mixes/04 - Mr. President - Coco Jamboo (Drs Botanical 12" mix).mp3:
TSSE (Software/Hardware and settings used for encoding): LAME 64bits version 3.99.5 (http://lame.sf.net)
TIT2 (Title/songname/content description): Coco Jamboo (Drs Botanical 12" mix)
TPE1 (Lead performer(s)/Soloist(s)): Mr. President
TALB (Album/Movie/Show title): Coco Jamboo: The Mixes
TYER (Year): 0
TLEN (Length): 420800
ArturSierzant commented 2 years ago

I tried to reproduce this error, but I can't. Could you please share this file (can be of course without music content)?

tomchiverton commented 2 years ago

I emailed the full file to info ~at~ ompd[.]pl

If I knew how to strip the music parts from the file I think I could attach just that here.

This is on Fedora Core 36, PHP 8.1.7

ArturSierzant commented 2 years ago

Thanks for that file - it helped a lot. This is how getID3 sees tags in your file (you can see it browsing files in O!MPD and choosing 'File details' from file hamburger menu):

obraz

There are some strange chars in YEAR tag. In latest commit 500f748 I modified (as you suggested) postProcessYear function and it seems to solve the problem. Please check if this helps also in your case.

BTW: I use PHP 8.0.18 and in my case this file didn't throw an error. Update continued, new album was added, but there was no data about track.

karltestano commented 1 year ago

Hello OMPD community!

Today i found the same problem and saw the solution but im my mp3 file some has written in the field "year" the string "60s", which i think the creator of the mp3 tag fills in, because he/she didn't know the correct entry.

See the fie infos ompd-01

With this file info and the new update.php you get the follwing error: PHP Fatal Error Uncaught mysqli_sql_exception: Unknown column '60s' in 'field list' in /var/www/ompd/update.php:1342 Stack trace: #0 /var/www/ompd/update.php(1342): mysqli_query() #1 /var/www/ompd/update.php(1213): fileInfo() #2 /var/www/ompd/update.php(401): fileInfoLoop() #3 /var/www/ompd/update.php(78): update() #4 {main} thrown File: /var/www/ompd/update.php Line: 1342

I updated then line 1338 in update.php from

year = ' . $db->real_escape_string(parseYear($metaData)) . ',

to

year = ' . (int) $db->real_escape_string(parseYear($metaData)) . ',

and the error went away.

Greetings

ArturSierzant commented 1 year ago

Thanks @karltestano for that - I finally corrected this issue in commit f2cf26e. I'm sorry it took me so long...

Greetings Artur