gitman328 / youtube-upload-mail-reminder

Receive a mail notification if your favorite YouTube channel has upload a video
https://yumr.me
4 stars 0 forks source link

Query for storing sent notification throws an error #4

Closed joergRossdeutscher closed 4 years ago

joergRossdeutscher commented 4 years ago

I installed fresh and came to the point where to setup the cronjob. Unlike the docs say I did not receive any notification mailo at all. I tracked that down to the SQL query that stores the notification in the database. This s the query that gets to be sent:

INSERT INTO `UCAiDWnTP0WB1xCp6uuUo0VA#1`
    (
    channel_name,
    video_title,
    video_id,
    video_thumbnail,
    timestamp,
    date,
    account
    ) VALUES (
    'Acorn To Arabella',
    'Mast Blocking and A New Tool - Episode 132 - Acorn to Arabella: Journey of a Wooden Boat',
    'YwWemUE9U-o',
    'https://i2.ytimg.com/vi/YwWemUE9U-o/hqdefault.jpg',
    '1602241207',
    '09.10.2020, 13:00:07',
    'joerg@###MY_EMAIL_ADDRESS_HERE###'
    )

Submitting this manually in mariadb I can see that query is not valid: Field 'notified' doesn't have a default value

The same happens later with Field 'notified_ts' doesn't have a default value

I still haven't got it finally working at the moment, but It looks like I am one step further with this change:

    $query="INSERT INTO `".$obj_1->channel_id."#".$obj_0->id."` 
    (
    channel_name, 
    video_title, 
    video_id, 
    video_thumbnail, 
    timestamp, 
    date, 
    account,
    notified,   
    notified_ts   
    ) VALUES (
    '".$channel_name."', 
    '".$video_title."', 
    '".$video_id."', 
    '".$video_thumbnail."', 
    '".$timestamp."', 
    '".date("d.m.Y, H:i:s", $timestamp)."', 
    '".$obj_0->mailadress."',
    1,
    UNIX_TIMESTAMP()
    ) 
    ";

    mysqli_query($dbmysqli, $query);
gitman328 commented 4 years ago

Probably Mariadb needs also a parameter for database cells which was not filled by that query. Dont know. I'm using MySQL.

The cells notified and notified_ts was only filled from mailer.php

If in cell notified is the parameter '1' before the script mailer.php was called, it doesnt send a mail for that video.

'1' means that a mail with that information was already send. So the content of cell notified must be zero '0' before mailer.php was executed.

I will add some code in script, that all cells be considered to prevent this issue.

joergRossdeutscher commented 4 years ago

Yes there should be a default value. Many users of Mariadb don't know that they are using Mariadb, because that's what you get for example in Debian Linux when installing Mysql. Mariadb is the drop-in replacement for Mysql.

I did not try, but I am surprised this works with mysql. There is no default value set for this field, so from my experience it's correct the query fails.

gitman328 commented 4 years ago

Fixed