<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -14,51 +14,17 @@
 #
 #
 
-$path = $0;
-$path =~ s/deletemovie.pl$//i;
-if ($pwd  ne &quot;./&quot;){
-push( @INC, &quot;$path&quot;);
-}
-
-require &quot;foltialib.pl&quot;;
+use strict;
+use warnings;
+use Carp;
+use Getopt::Long;
+use Foltia;
 
 #&#176;&#250;&#164;&#173;&#191;&#244;&#164;&#172;&#165;&#162;&#165;&#235;&#164;&#171;?
-$fname = $ARGV[0] ;
-if ($fname eq &quot;&quot; ){
-	#&#176;&#250;&#164;&#173;&#191;&#244;&#164;&#202;&#164;&#183;&#189;&#208;&#188;&#194;&#185;&#212;&#164;&#181;&#164;&#236;&#164;&#191;&#164;&#233;&#161;&#162;&#189;&#170;&#206;&#187;
-	print &quot;usage;deletemovie.pl &lt;FILENAME&gt;\n&quot;;
-	exit;
-}
-
-#&#165;&#213;&#165;&#161;&#165;&#164;&#165;&#235;&#204;&#190;&#192;&#181;&#197;&#246;&#192;&#173;&#165;&#193;&#165;&#167;&#165;&#195;&#165;&#175;
-if ($fname =~ /.m2p\z/){
-
-}else{
-#	print &quot;deletemovie invalid filetype.\n&quot;;
-	&amp;writelog(&quot;deletemovie invalid filetype:$fname.&quot;);
-	exit (1);
-}
-
-#&#165;&#213;&#165;&#161;&#165;&#164;&#165;&#235;&#194;&#184;&#186;&#223;&#165;&#193;&#165;&#167;&#165;&#195;&#165;&#175;
-
-if (-e &quot;$recfolderpath/$fname&quot;){
-
-}else{
-#	print &quot;deletemovie file not found.$recfolderpath/$fname\n&quot;;
-	&amp;writelog(&quot;deletemovie file not found:$fname.&quot;);
-	exit (1);
-}
-
-#&#180;&#251;&#198;&#201;&#186;&#239;&#189;&#252;&#189;&#232;&#205;&#253; 
-if ($rapidfiledelete  &gt; 0){ #./mita/&#164;&#216;&#176;&#220;&#198;&#176;
-	system (&quot;mv $recfolderpath/$fname $recfolderpath/mita/&quot;);
-	&amp;writelog(&quot;deletemovie mv $recfolderpath/$fname $recfolderpath/mita/.&quot;);
-}else{ #&#194;&#168;&#187;&#254;&#186;&#239;&#189;&#252;
-	system (&quot;rm $recfolderpath/$fname &quot;);
-	&amp;writelog(&quot;deletemovie rm $recfolderpath/$fname &quot;);
-
-
-}
-
+GetOptions('-f=s' =&gt; \my $file);
 
+#&#176;&#250;&#164;&#173;&#191;&#244;&#164;&#202;&#164;&#183;&#189;&#208;&#188;&#194;&#185;&#212;&#164;&#181;&#164;&#236;&#164;&#191;&#164;&#233;&#161;&#162;&#189;&#170;&#206;&#187;
+$file or die &quot;Usage: deletemovie.pl &lt;FILENAME&gt;\n&quot;;
 
+my $f = new Foltia;
+$f-&gt;video-&gt;deletemovie($file);</diff>
      <filename>bin/deletemovie.pl</filename>
    </modified>
    <modified>
      <diff>@@ -14,35 +14,22 @@
 # DCC-JPL Japan/foltia project
 #
 #
-use DBI;
-use DBD::Pg;
-use Schedule::At;
-use Time::Local;
+use strict;
+use warnings;
+use Carp;
+use Getopt::Long;
+use Foltia;
 
 
-$path = $0;
-$path =~ s/folprep.pl$//i;
-if ($pwd  ne &quot;./&quot;){
-push( @INC, &quot;$path&quot;);
-}
-
-require &quot;foltialib.pl&quot;;
-
-#XML&#165;&#178;&#165;&#195;&#165;&#200; &amp; DB&#185;&#185;&#191;&#183;
-system(&quot;$toolpath/perl/getxml2db.pl&quot;);
-
-#&#176;&#250;&#164;&#173;&#191;&#244;&#164;&#172;&#165;&#162;&#165;&#235;&#164;&#171;?
-$pid = $ARGV[0] ;
-if ($pid eq &quot;&quot; ){
-	#&#176;&#250;&#164;&#173;&#191;&#244;&#164;&#202;&#164;&#183;&#189;&#208;&#188;&#194;&#185;&#212;&#164;&#181;&#164;&#236;&#164;&#191;&#164;&#233;&#161;&#162;&#189;&#170;&#206;&#187;
-	print &quot;usage;folprep.pl &lt;PID&gt;\n&quot;;
-	exit;
-}
+GetOptions('-p=s' =&gt; \my $pid)
+#&#176;&#250;&#164;&#173;&#191;&#244;&#164;&#202;&#164;&#183;&#189;&#208;&#188;&#194;&#185;&#212;&#164;&#181;&#164;&#236;&#164;&#191;&#164;&#233;&#161;&#162;&#189;&#170;&#206;&#187;
+$pid or die &quot;Usage: folprep.pl &lt;PID&gt;\n&quot;;
 
 #PID&#195;&#181;&#164;&#183;
-$pid = $ARGV[0];
 
 #&#165;&#173;&#165;&#229;&#161;&#188;&#186;&#198;&#197;&#234;&#198;&#254;
-	&amp;writelog(&quot;folprep  $toolpath/perl/addpidatq.pl $pid&quot;);
-system(&quot;$toolpath/perl/addpidatq.pl $pid&quot;);
+Foltia::Util::writelog(&quot;folprep addpidatq $pid&quot;);
+my $f = new Foltia;
+$f-&gt;db-&gt;addpidatq($pid);
+
 </diff>
      <filename>bin/folprep.pl</filename>
    </modified>
    <modified>
      <diff>@@ -10,61 +10,17 @@
 # DCC-JPL Japan/foltia project
 #
 #
+use strict;
+use warnings;
+use Carp;
+use Getopt::Long;
+use Foltia;
 
 
-use Jcode;
-use DBI;
-use DBD::Pg;
+GetOptions('-t=s' =&gt; \my $tid)
 
+#&#176;&#250;&#164;&#173;&#191;&#244;&#164;&#172;&#165;&#162;&#165;&#235;&#164;&#171;?	#&#176;&#250;&#164;&#173;&#191;&#244;&#164;&#202;&#164;&#183;&#189;&#208;&#188;&#194;&#185;&#212;&#164;&#181;&#164;&#236;&#164;&#191;&#164;&#233;&#161;&#162;&#189;&#170;&#206;&#187;
+$tid or die &quot;Usage: mklocalizeddir.pl [TID]\n&quot;;
 
-$path = $0;
-$path =~ s/mklocalizeddir.pl$//i;
-if ($pwd  ne &quot;./&quot;){
-push( @INC, &quot;$path&quot;);
-}
-require &quot;foltialib.pl&quot;;
-
-#&#176;&#250;&#164;&#173;&#191;&#244;&#164;&#172;&#165;&#162;&#165;&#235;&#164;&#171;?
-$tid =  $ARGV[0] ;
-if ($tid eq &quot;&quot; ){
-	#&#176;&#250;&#164;&#173;&#191;&#244;&#164;&#202;&#164;&#183;&#189;&#208;&#188;&#194;&#185;&#212;&#164;&#181;&#164;&#236;&#164;&#191;&#164;&#233;&#161;&#162;&#189;&#170;&#206;&#187;
-	print &quot;usage mklocalizeddir.pl [TID]\n&quot;;
-	exit;
-}
-
-
-#&#164;&#189;&#164;&#206;&#165;&#199;&#165;&#163;&#165;&#236;&#165;&#175;&#165;&#200;&#165;&#234;&#164;&#172;&#164;&#202;&#164;&#177;&#164;&#236;&#164;&#208;
-if (-e &quot;$recfolderpath/$tid.localized&quot;){
-
-}else{
-
-
-#.localized&#205;&#209;&#202;&#184;&#187;&#250;&#206;&#243;&#188;&#232;&#198;&#192;
-
-#&#192;&#220;&#194;&#179;
-	my $data_source = sprintf(&quot;dbi:%s:dbname=%s;host=%s;port=%d&quot;,
-		$DBDriv,$DBName,$DBHost,$DBPort);
-	 $dbh = DBI-&gt;connect($data_source,$DBUser,$DBPass) ||die $DBI::error;;
-
-#&#184;&#161;&#186;&#247;
-$DBQuery =  &quot;select title from foltia_program where tid=$tid &quot;;
-	 $sth = $dbh-&gt;prepare($DBQuery);
-	$sth-&gt;execute();
- @subticount= $sth-&gt;fetchrow_array;
-$title = $subticount[0] ;
-$titleeuc = $title ;
- Jcode::convert(\$title , 'utf8', 'euc', &quot;z&quot;);
-
-
-	mkdir (&quot;$recfolderpath/$tid.localized&quot;,0755);
-	mkdir (&quot;$recfolderpath/$tid.localized/.localized&quot;,0755);
-	mkdir (&quot;$recfolderpath/$tid.localized/mp4&quot;,0755);
-	mkdir (&quot;$recfolderpath/$tid.localized/m2p&quot;,0755);
-	open (JASTRING,&quot;&gt;$recfolderpath/$tid.localized/.localized/ja.strings&quot;)  || die &quot;Cannot write ja.strings.\n&quot;;
-	print JASTRING &quot;\&quot;$tid\&quot;=\&quot;$title\&quot;;\n&quot;;
-	close(JASTRING);
-
-&amp;writelog(&quot;mklocalizeddir $tid $titleeuc&quot;);
-
-}#unless &#176;&#250;&#164;&#173;&#191;&#244;&#164;&#172;&#165;&#162;&#165;&#235;&#164;&#171;?
-
+my $f = new Foltia;
+$f-&gt;video-&gt;mklocalizeddir($tid);</diff>
      <filename>bin/mklocalizeddir.pl</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,8 @@ use DBI;
 use DBD::Pg;
 use Schedule::At;
 use Time::Local;
+use Encode;
+use Encode::Guess qw/utf8 euc-jp shiftjis 7bit-jis/;
 
 __PACKAGE__-&gt;mk_accessors(qw/config/);
 
@@ -307,4 +309,65 @@ sub addpidatq {
 }
 
 
+sub deletemovie {
+    my ($self, $file) = @_;
+    #&#12501;&#12449;&#12452;&#12523;&#21517;&#27491;&#24403;&#24615;&#12481;&#12455;&#12483;&#12463;
+    if (! $file =~ /.m2p\z/){
+    #	print &quot;deletemovie invalid filetype.\n&quot;;
+        my $msg = &quot;deletemovie invalid filetype: $file.&quot;;
+        writelog($msg);
+        warn $msg;
+        return 0;
+    }
+
+    #&#12501;&#12449;&#12452;&#12523;&#23384;&#22312;&#12481;&#12455;&#12483;&#12463;
+    my $filepath = $self-&gt;config-&gt;recfolderpath . $file;
+    if (-e $filepath) {
+    # print &quot;deletemovie file not found.$recfolderpath/$fname\n&quot;;
+        my $msg = &quot;deletemovie file not found: $file.&quot;;
+        writelog($msg);
+        warn $msg;
+        return 0;
+    }
+
+    #&#26082;&#35501;&#21066;&#38500;&#20966;&#29702;
+    if ($self-&gt;config-&gt;rapidfiledelete &gt; 0){ #./mita/&#12408;&#31227;&#21205;
+        my $trashpath = $self-&gt;config-&gt;trashpath;
+        system (&quot;mv $filepath $trashpath&quot;);
+        writelog(&quot;deletemovie mv $filepath $trashpath.&quot;);
+    }else{ #&#21363;&#26178;&#21066;&#38500;
+        system (&quot;rm $filepath&quot;);
+        writelog(&quot;deletemovie rm $filepath &quot;);
+    }
+}
+
+sub mklocalizeddir {
+    my ($self, $tid) = @_;
+
+    #&#12381;&#12398;&#12487;&#12451;&#12524;&#12463;&#12488;&#12522;&#12364;&#12394;&#12369;&#12428;&#12400;
+    my $dirname = $self-&gt;config-&gt;recfolderpath . $tid . '.localized';
+    return 0 if (-e $dirname);
+
+    #.localized&#29992;&#25991;&#23383;&#21015;&#21462;&#24471;
+
+    #&#26908;&#32034;
+    my $DBQuery =  &quot;select title from foltia_program where tid=$tid &quot;;
+    my $sth = $self-&gt;dbh-&gt;prepare($DBQuery);
+	$sth-&gt;execute();
+    my @subticount= $sth-&gt;fetchrow_array;
+    my $title = $subticount[0];
+
+	mkdir (&quot;$dirname&quot;,0755);
+	mkdir (&quot;$dirname/.localized&quot;,0755);
+	mkdir (&quot;$dirname/mp4&quot;,0755);
+	mkdir (&quot;$dirname/m2p&quot;,0755);
+	open (JASTRING,&quot;&gt;$dirname/.localized/ja.strings&quot;)  || die &quot;Cannot write ja.strings.\n&quot;;
+	print JASTRING &quot;\&quot;$tid\&quot;=\&quot;$title\&quot;;\n&quot;;
+	close(JASTRING);
+
+    my $utf8title = decode(&quot;Guess&quot;, $title);
+    #writelog(&quot;mklocalizeddir $tid &quot; . encode('utf8', $utf8title));
+    writelog(&quot;mklocalizeddir $tid &quot; . encode('euc-jp', $utf8title));
+}
+
 1;</diff>
      <filename>lib/Foltia/Video.pm</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>02d0a00b7509b3970a8b61feefe3d1cb5a8169e3</id>
    </parent>
  </parents>
  <author>
    <name>koshian</name>
    <email>koshian@foxking.org</email>
  </author>
  <url>http://github.com/koshian/foltia-the-next-generation/commit/1394b047e35988e97999f0889d90b71bc6f5e1f9</url>
  <id>1394b047e35988e97999f0889d90b71bc6f5e1f9</id>
  <committed-date>2008-06-15T20:03:54-07:00</committed-date>
  <authored-date>2008-06-15T20:03:54-07:00</authored-date>
  <message>Fix some *.pl for new Foltia.pm</message>
  <tree>921aac399a44ee661041a2d8a8482c9b71c95416</tree>
  <committer>
    <name>koshian</name>
    <email>koshian@foxking.org</email>
  </committer>
</commit>
