further work... nothing reaaaally good yet, but getting there.
This commit is contained in:
@@ -19,7 +19,7 @@ $plugin['flags'] = PLUGIN_LIFECYCLE_NOTIFY;
|
||||
// @include_once('zem_tpl.php');
|
||||
|
||||
register_callback('bts_podcast_initdb','plugin_lifecycle.bts_podcast', 'enabled');
|
||||
register_callback('bts_podcast_genguid','article_saved');
|
||||
register_callback('bts_podcast_gen_metainfo','article_saved');
|
||||
|
||||
if (0) {
|
||||
?>
|
||||
@@ -88,15 +88,21 @@ This plugin creates a *sha256* table in your Textpattern DB. There, it stores th
|
||||
|
||||
# --- BEGIN PLUGIN CODE ---
|
||||
|
||||
// Hooks
|
||||
// Hooks/callbacks
|
||||
function bts_podcast_initdb () {
|
||||
safe_query("CREATE TABLE IF NOT EXISTS sha256 (id int(11) NOT NULL AUTO_INCREMENT,url_title varchar(64) NOT NULL,filename varchar(64) NOT NULL,type char(3) NOT NULL,checksum char(64) NOT NULL,created datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,changed timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,PRIMARY KEY (id),UNIQUE KEY `unique_index` (url_title,type)");
|
||||
safe_query("CREATE TABLE IF NOT EXISTS bts_podcast (id int(11) NOT NULL AUTO_INCREMENT,url_title varchar(64) NOT NULL,filename varchar(64) NOT NULL,type char(3) NOT NULL,checksum char(64) NOT NULL,bytesize varchar(16) NOT NULL,created datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,changed timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,PRIMARY KEY (id),UNIQUE KEY unique_index (url_title,type)) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8");
|
||||
}
|
||||
|
||||
function bts_podcast_gen_guid () {
|
||||
hash_file('sha256',file_article_upload());
|
||||
function bts_podcast_gen_metainfo ($input) {
|
||||
$hash = hash_file('sha256',file_article_upload());
|
||||
// safe_query("INSERT INTO bts_podcast (url_title,filename,type,checksum,bytesize) VALUES ('" . $input['urltitle'] . "','" . $input['mediafile'] . "','" . $input['mediatype'] . "','" . $input['mediachksum'] . "','" . $input['mediabytes'] . "') ON DUPLICATE KEY UPDATE url_title = '" . $input['urltitle'] . "', filename = '" . $input['mediafile'] . "', type = '" . $input['mediatype'] . "', checksum = '" . $input['mediachksum'] . "', bytesize = '" . $input['mediabytes'] . "'");
|
||||
}
|
||||
|
||||
//use pluggable_ui(event,step,default content, record set)
|
||||
//event, i believe, is article_ui
|
||||
//maybe use step "custom_fields" and totally replace custom fields with the file uploader?
|
||||
//i should also find a way to get the "S0E0" format automatically used for the url title/permlink.
|
||||
|
||||
// Register the plugin...
|
||||
if(class_exists('\Textpattern\Tag\Registry')) {
|
||||
Txp::get('\Textpattern\Tag\Registry')
|
||||
@@ -142,7 +148,7 @@ function bts_podcast_guid ($atts) {
|
||||
), $atts));
|
||||
|
||||
if (($byte == '1' && $db == '1') || ($string == '')) {
|
||||
$checksum = fetch('checksum','sha256','filename',bts_podcast_filename($atts));
|
||||
$checksum = fetch('checksum','bts_podcast','filename',bts_podcast_filename($atts));
|
||||
} elseif ($byte == '1') {
|
||||
$checksum = hash_file('sha256',$string);
|
||||
} else {
|
||||
@@ -156,13 +162,49 @@ function bts_podcast_media_uri ($atts) {
|
||||
$default_vals = array('media' => 'mp3');
|
||||
$default_vals['uri'] = site_url($atts) . bts_podcast_path($atts) . bts_podcast_filename($atts);
|
||||
extract(lAtts(array($default_vals), $atts));
|
||||
if ( $uri == '') {
|
||||
if (! isset($uri)) {
|
||||
$uri = site_url($atts) . bts_podcast_path($atts) . bts_podcast_filename($atts);
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/*
|
||||
function bts_podccast_filesize($atts) {
|
||||
}
|
||||
function bts_podcast_medialength($atts) {
|
||||
}
|
||||
function bts_podcast_get_guid($atts) {
|
||||
}
|
||||
*/
|
||||
|
||||
// UNDER DEVELOPMENT: needs bts_podcast_filesize (which i need to rename to actually be bytesize)
|
||||
// i also need to get media length so that can be returned in the actual feed.
|
||||
/*
|
||||
$metainfo_mp3 = array(
|
||||
//$input['urltitle']
|
||||
//$input['mediafile']
|
||||
//$input['mediatype']
|
||||
//$input['mediachksum']
|
||||
//$input['mediabytes']
|
||||
urltitle => title($atts),
|
||||
mediafile => bts_podcast_filename($atts),
|
||||
mediatype => 'mp3',
|
||||
mediachksum => bts_podcast_guid($atts),
|
||||
mediabytes => bts_podcast_filesize($atts));
|
||||
$metainfo_ogg = array(
|
||||
//$input['urltitle']
|
||||
//$input['mediafile']
|
||||
//$input['mediatype']
|
||||
//$input['mediachksum']
|
||||
//$input['mediabytes']
|
||||
urltitle => title($atts),
|
||||
mediafile => bts_podcast_filename($atts),
|
||||
mediatype => 'mp3',
|
||||
mediachksum => bts_podcast_guid($atts),
|
||||
mediabytes => bts_podcast_filesize($atts));
|
||||
bts_podcast_gen_metainfo ($metainfo_mp3);
|
||||
bts_podcast_gen_metainfo ($metainfo_ogg);
|
||||
*/
|
||||
# --- END PLUGIN CODE ---
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user