| *ta^da*
;-) here it is, sorry i've take
forever to post it. my lil php progie moves gpodder's podcast
downloads into an easy to understand dir structure. e.g., 'Podcasts
name'(dir)/'Podcasts'... so you can setup play lists, browse them, and
etc. it can also use gPodder to download any new podcasts before
moving podcasts. it has a '--help' option which explains more. i'll
be posting updates to my website and prolly here too. i'll help out
with any questions or problems anyone has as much as i'm able. i hope
it helps everyone as much i love it.
|
goodness, love, &caring,
Katy... blessed be. healthy, hopeful,
&safe may we all always be ^_^
I have 'it', thousands do, and you've
probably never heard of 'it'. 'it' twists our bodies, 'it' can ruin our lives; and
occasionally 'it' will take
them... what 'it' cannot twist,
ruin, or take is our DREAMS! 'it' is Generalized
Dystonia!
|
|
help test firefox3 &rediscover
the web! |
|
#!/usr/bin/php
<?php
/*TODO: i want to add more comments so gPodderDoesWeirdStuff
is more understandable. but even as it is, i'm pretty proud of it.
its simply, quick, &makes watching &listening to podcasts like tons
easier.
*hugs* &super big thnx Thomas,
for writing &working on gPodder and i hope that i get to
contribute a lot mor than just this script in the future.
what i hoping to contribute next is a playlist creator
that will make watching &listening to podcasts from right
inside gPodder like way easier.
*/
/*
(c) 2007-Present Katy G. B. <[EMAIL PROTECTED]>
Writen by a disabled uberChick. i have Generalized Dystonia.
if you like any of my software, or script, please visit one of
my myspace pages at:
http://www.myspace.com/uberchicgeekchick (my geekChick
stuff)
or
http://www.myspace.com/imdesigningdreams (my MUCH more
personal stuff)
if you go there thinking 'MUCH more personal' means
naughty you'll sorely reget it!
currently all of my software is released under the RPL, but i'm
working
on my own license focused on software writen by myself and other
open source internet artists(web design &developers)
if you'd like to help or contribute on the new license
please, please, pretty please contact me.
--------------------------- current RPL disclaimer
------------------------------
| a opy of the RPL may be found with this project or
online at |
| http://www.technicalpursuit.com/licenses/RPL_1.3.html
|
---------------------------------------------------------------------------------
Unless explicitly acquired and licensed from Licensor under
another license,
the contents of this file are subject to the Reciprocal Public
License
("RPL")
Version 1.3, or subsequent versions as allowed by the RPL, and
You
may not copy or use this file in either source code or
executable
form, except in compliance with the terms and conditions of the
RPL.
All software distributed under the RPL is provided strictly on
an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, AND
LICENSOR HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING
WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
FOR
A PARTICULAR PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See
the
RPL for specific language governing rights and limitations under
the RPL.
*/
function gPodderDoesWeirdStuff_help() {
print("Usage: {$PHP_SELF} [options]..."
."\n\toptions:"
."\n"
."\n\t--help displays this screen."
."\n"
."\n"
."\n\t--keep-original keeps gPodders GUID
named files while making hard-links to all"
."\n\t podcasts with easier to
understand directories &filenames."
."\n"
."\n"
."\n\t--update runs `gpodder --run`
automatically before moving podcasts."
."\n"
."\n"
."\n\t--quiet surpresses all
messages. this effects different messages ."
."\n"
."\n\t--leave-trail thise makes
gPodderDoesWeirdStuff leave [GUID].trail files."
."\n\t these are symlinks to
gPodder's GUID folder."
."\n"
."\n"
."\n\t--verbose outputs very verbose
debugging messages about whats happening"
."\n\t for when gPodder isn't
displaying my channel listings."
."\n\t if that's all you want
gPodderDoesWeirdStuff to do than use"
."\n\t using this switch will
fix everything without moving any"
."\n\t downloaded podcasts."
."\n"
."\n"
."\n"
."\n\t *wink* &remember gPodderDoesWeirdStuff
is written in PHP;"
."\n\t so it should be super easy to
customize."
);
exit(0);
}//end 'gPodderDoesWeirdStuff_help' function.
function gPodderDoesWeirdStuff_grabSettings() {
/* here's where i setup and check all the directories i
need
to use, find, &rename/move all of my podcasts and their
names and etc.
*/
if(((
(is_dir(
(((($GLOBALS['gPodderConfigDir']=(getenv("HOME"))."/.config/gpodder"))))
))
&&
(
((($GLOBALS['homeDir']=ltrim(exec("grep
--max-count=1 'download_dir' {$GLOBALS['gPodderConfigDir']}/gpodder.conf|cut
-d'=' -f2")))))
&&
(
((is_dir($GLOBALS['homeDir'])) &&
(is_dir(dirname($GLOBALS['homeDir']))))
&&
((chdir(dirname($GLOBALS['homeDir'])))
&& (basename($GLOBALS['homeDir'])))
)
)
)))
return TRUE;
print("Unable to load gPodder configuration."
."\n\ti tried to read gPodders configuration from:"
."\n\t\t{$GLOBALS['gPodderConfigDir']}/gpodder.conf"
);
exit(-1);
}//end of 'gPodderDoesWeirdStuff_grabSettings' function.
function gPodderDoesWeirdStuff_setup() {
/* check to make sure that gPodder has already been
converted to download
podcasts to a hidden directory. so than i can
move/hard-link podcasts
in the non-hidden directory with the original name.
*/
exec("sed
--expression='1,$s/^\(download_dir.*\)\/\([^\/]*\)$/\1\/\.\2/'
{$GLOBALS['gPodderConfigDir']}/gpodder.conf
>{$GLOBALS['gPodderConfigDir']}/new_gPodder.conf");
rename("{$GLOBALS['gPodderConfigDir']}/new_gPodder.conf",
"{$GLOBALS['gPodderConfigDir']}/gpodder.conf");
rename(GPODDER_DL_DIR, ".".GPODDER_DL_DIR);
if(!(in_array("--quiet", $GLOBALS['argv'])))
print("gPodder's actual/temporary download directory is
now hidden."
."\ngPodder's original download directory will"
."\ncontain podcasts in an easily browsable
structure."
."\ngpodder.conf has also been updated."
."\n"
."\nso gPodder will now download podcasts to
the hidden directory:"
."\n\t".(dirname($GLOBALS['homeDir']))."/.".GPODDER_DL_DIR
."and podcasts will be moved(hard-linked) to
when gPodderDoesWeirdStuff's ran:"
."\n\t".(dirname($GLOBALS['homeDir']))."/".GPODDER_DL_DIR
."\nwhere you can easily browse and organize
podcasts &playlists."
);
}//end 'gPodderDoesWeirdStuff_setup' function.
function gPodderDoesWeirdStuff_downloadPodcasts() {
if(!((is_executable(($gpodderProgie=exec("which gpodder"))))))
return (((in_array("--quiet", $GLOBALS['argv']))
?("can't find gPodder in path.")
:(print("i can't try to download any new
podcasts."
."\ni couldn't find gPodder in your
path."
))
));
if(
(!((in_array("--quiet", $GLOBALS['argv']))))
||
(((in_array("--verbose", $GLOBALS['argv']))))
)
print("Please wait while gPodder downloads any new
podcasts.\n\n");
if(!((in_array("--verbose", $GLOBALS['argv']))))
exec("{$gpodderProgie} --run");
else
system("{$gpodderProgie} --run");
}//end 'gPodderDoesWeirdStuff_downloadPodcasts' function.
//here's where my progie gPodderDoesWeirdStuff actually starts.
if((in_array("--help", $GLOBALS['argv'])))
gPodderDoesWeirdStuff_help();//this exits gPodderDoesWeirdStuff
if(!((gPodderDoesWeirdStuff_grabSettings())))
exit(-1);
if(!(preg_match("/^\./", (basename($homeDir)))))
gPodderDoesWeirdStuff_setup();
define("GPODDER_DL_DIR", preg_replace("/^\.?/", "",
(basename($homeDir))));
define("TODAYS_DATETIME", date("Y-m-d @ h:ip"));
if((in_array("--update", $GLOBALS['argv'])))
gPodderDoesWeirdStuff_downloadPodcasts();
$totalMovedPodcasts=0;
$gPoddersPodcastDir=opendir(".".GPODDER_DL_DIR);
while($podcastsGUID=readdir($gPoddersPodcastDir)) {
/* if a podcast's 'cover' file is not a valid image gPodder
won't
show the channels. so here i check just to make sure, that
if
this podcast has a 'cover' file, that its a valid image. and
not just another kinda file, like an xhtml or xml file.
*/
if(!((is_dir(".".GPODDER_DL_DIR."/".$podcastsGUID))))
continue;
if((in_array("--leave-trail", $GLOBALS['argv'])))
symlink(".".GPODDER_DL_DIR."/".$podcastsGUID,
GPODDER_DL_DIR."/{$podcastsName}/{$podcastsGUID}.trail"
);
/* here i try to load this podcast's 'index.xml' file.
if i can't find it, i'll try and find it in gPodder's cache,
if i find there i'll restore it; if not i have to skip-it.
*/
$podcastsXML=".".GPODDER_DL_DIR."/".$podcastsGUID."/index.xml";
if(!((is_readable($podcastsXML))))
if(!((is_readable("{$gPodderConfigDir}/cache/{$podcastsGUID}.xml"))))
continue;
else
copy("{$gPodderConfigDir}/cache/{$podcastsGUID}.xml", $podcastsXML);
$podcastsFiles=array();
exec("ls -t --width=1
.".GPODDER_DL_DIR."/".$podcastsGUID."/*.*|cut -d'/' -f3", $podcastsFiles);
if((($podcastsFiles['total']=count($podcastsFiles))==1))
continue;
$podcastsInfo=array();
exec("grep '<title>' {$podcastsXML}|cut -d'>' -f2|cut -d'<'
-f1", $podcastsInfo);
$podcastsInfo['total']=count($podcastsInfo);
if($podcastsInfo['total']<2)
continue;
/* replaces forward slashes with hyphens &removes leading
dots('.').
both for obvious(linux) reasons.
*/
for($i=0; $i<$podcastsInfo['total']; $i++)
$podcastsInfo[$i]=preg_replace("/\//", ":",
preg_replace("/^[.]*/", "", $podcastsInfo[$i])
);
$podcastsName=$podcastsInfo[0];
//no show name's found
if(($podcastsFiles['total']>$podcastsInfo['total']))
for($i=count($podcastsInfo), $z=1;
$i<=$podcastsFiles['total']; $i++, $z++)
$podcastsInfo[$i]="{$podcastsName} show {$z}
from ".TODAYS_DATETIME;
$podcastsInfo['total']=$podcastsFiles['total'];
if(!((is_dir(GPODDER_DL_DIR."/".$podcastsName))))
if(!((mkdir(GPODDER_DL_DIR."/".$podcastsName, 0744,
TRUE)))) {
printf("\n\ti have to skip %s because i
couldn't create it's directory. please edit '%s' to fix this issue.",
$podcastsName, $podcastsXML);//*wink*, it just kinda felt like a printf moment
:P
continue;
}
if(!(in_array("--quiet", $GLOBALS['argv']))) {
if($totalMovedPodcasts)
print("\n");
print("\nMoving: {$podcastsName}");
}
$movedPodcasts=0;
for($i=1; $i<$podcastsFiles['total']; $i++) {
$podcastsInfo[$i]=preg_replace("/[\.]*$/", "",
$podcastsInfo[$i]);
$ext="";
while((
($i<$podcastsFiles['total'])
&&
(($ext=preg_replace("/^[^\.]*(\.[a-zA-Z0-9]{3,4})$/", "$1", $podcastsFiles[$i]))
==
"xml")
))
$i++;
if( ($i <= $podcastsFiles['total']) )
continue;
if(in_array("--verbose", $GLOBALS['argv']))
print("\n\tMoving:\n\t.".GPODDER_DL_DIR."/".$podcastsGUID."/".$podcastsFiles[$i]
."\n\t\tto"
."\n\t".GPODDER_DL_DIR."/".$podcastsName."/".$podcastsInfo[$i].$ext
);
if(!( (in_array("--leave-trail", $GLOBALS['argv'])) )) {
$a=2;
$subfix="";
$podcastsTestingInfo=$podcastsInfo[$i];
while((file_exists(GPODDER_DL_DIR."/{$podcastsName}/{$podcastsTestingInfo}{$ext}")))
{
$podcastsTestingInfo=$podcastsInfo[$i]
.($subfix=" - "
.( ($a < 100)
?( ($a < 10) ?"00" :"0"
)
:""
)
.$a++
);
}
if(($subfix)) {
rename(
GPODDER_DL_DIR."/{$podcastsName}/{$podcastsInfo[$i]}{$ext}",
GPODDER_DL_DIR."/{$podcastsName}/{$podcastsInfo[$i]} - {$subfix}{$ext}"
);
$podcastsInfo[$i]=$podcastsTestingInfo;
}
unset($a);
unset($subfix);
}
if((
(((
(link(
(".".GPODDER_DL_DIR."/".$podcastsGUID."/".$podcastsFiles[$i]),
(GPODDER_DL_DIR."/".$podcastsName."/".$podcastsInfo[$i].$ext)
))
))) //why so many? so i create the hardlink
before i check arguments.
&&
(!((in_array("--keep-original",
$GLOBALS['argv']))))
)) {
$movedPodcasts++;
if(in_array("--verbose", $GLOBALS['argv']))
print("\n\t\t----Moved
successfully----");
unlink(".".GPODDER_DL_DIR."/".$podcastsGUID."/".$podcastsFiles[$i]);
}
}
if(in_array("--verbose", $GLOBALS['argv'])) {
print("\nMoved {$movedPodcasts} of {$podcastsName}'s
podcasts.");
$totalMovedPodcasts+=$movedPodcasts;
}
}
closedir($gPoddersPodcastDir);
if(in_array("--verbose", $GLOBALS['argv']))
print("\n\n\nMoved {$totalMovedPodcasts} total podcasts.");
?>
_______________________________________________
gpodder-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/gpodder-devel