#!/usr/local/bin/perl use Glib; use Gtk2 -init; use Gtk2::SimpleList; use Gtk2::Gdk::Keysyms; use Data::Dumper; use XML::RAI; if ($ARGV[0] =~ /\-clearoptions/) { if (`ls ~/.tvrss 2>&1` =~ /No such file or directory/) { printf "No options to clear.\n"; exit; } $checkforwipe = `which wipe 2>&1`; if ($checkforwipe =~ /\/.*\/wipe/) { `cd $ENV{'HOME'} && wipe -s .tvrss`; printf "Options cleared.\n"; exit; } else { `rm -f ~/.tvrss`; `rm -f ~/.tvrssurl`; printf "Options cleared.\n"; exit; } } @tvicon = ( '36 36 289 2', ' c None','. c #656565','+ c #404040','@ c #868686','# c #525252','$ c #6D6D6D','% c #7C7C7C','& c #1C1C1C','* c #969696','= c #989898','- c #6C6C6C','; c #818181','> c #929292',', c #595959','" c #747474',') c #838383','! c #6F6F6F','~ c #767676','{ c #141414','] c #434343','^ c #3F3F3F','/ c #848484','( c #737373','_ c #626262',': c #9E9E9E','< c #707070','[ c #7E7E7E','} c #AFAFAF','| c #C4C4C4','1 c #575757','2 c #4C4C4C','3 c #7F7F7F','4 c #979797','5 c #A09F9F','6 c #B6B6B6','7 c #A1A1A1','8 c #CDCDCD','9 c #E1E1E1','0 c #EAEAEA','a c #D6D6D6','b c #686868','c c #484848','d c #666666','e c #8C8C8C','f c #A4A4A4','g c #6B6B6B','h c #C9C9C9','i c #E0E0E0','j c #DDDDDD','k c #DADADA','l c #CECECE','m c #D0D0D0','n c #E2E2E2','o c #EBEBEB','p c #202020','q c #C5C5C5','r c #D9D9D9','s c #DCDCDC','t c #B9B9B9','u c #898989','v c #BABABA','w c #F1F1F1','x c #E3E3E3','y c #D4D4D4','z c #E6E6E6','A c #ECECEC','B c #777777','C c #EFEFEF','D c #F9F9F9','E c #FBFBFB','F c #F5F5F5','G c #A0A0A0','H c #A9A9A9','I c #C3C3C3','J c #D7D7D7','K c #E8E8E8','L c #D8D8D8','M c #C8C8C8','N c #C7C7C7','O c #CFCFCF','P c #D3D3D3','Q c #646464','R c #F3F3F3','S c #EDEDED','T c #BFBFBF','U c #B7B7B7','V c #D5D5D5','W c #CBCBCB','X c #CCCCCC','Y c #D2D2D2','Z c #C2C2C2','` c #B1B1B2',' . c #AAA9AA','.. c #909090','+. c #E4E4E4','@. c #DBDBDB','#. c #C6C6C6','$. c #DFDFDF','%. c #9C9999','&. c #857270','*. c #504B75','=. c #3A336B','-. c #494754',';. c #C9CACA','>. c #C3CAC7',',. c #97A79B','". c #7F7677','). c #894165','!. c #A63261','~. c #B83E3D','{. c #C94F43',']. c #4A3E96','^. c #3B3182','/. c #494659','(. c #696969','_. c #DEDEDE',':. c #D1D1D1','<. c #B3B39F','[. c #909F88','}. c #59838D','|. c #417A6E','1. c #3C8750','2. c #7F7971','3. c #E0589D','4. c #E9639D','5. c #DB7677','6. c #D7786E','7. c #6258A4','8. c #463C89','9. c #474456','0. c #9C9C7F','a. c #A2A12C','b. c #9BBB61','c. c #68A9B9','d. c #72B4A9','e. c #6FB782','f. c #A29F96','g. c #E671AD','h. c #E65894','i. c #D0504F','j. c #C94437','k. c #322588','l. c #251974','m. c #3C394D','n. c #6B6A6A','o. c #616161','p. c #BCBCBC','q. c #A4A353','r. c #E2E128','s. c #C6DD97','t. c #84BCC9','u. c #69B0A2','v. c #45A25E','w. c #786F66','x. c #DB2984','y. c #E02474','z. c #C83130','A. c #C43224','B. c #281B83','C. c #221671','D. c #363447','E. c #5E5E5E','F. c #C0C0C0','G. c #B8B8B8','H. c #B5B456','I. c #ECEC40','J. c #C2DBA2','K. c #62AABB','L. c #329382','M. c #21903E','N. c #6A6659','O. c #DA2782','P. c #C83030','Q. c #281A83','R. c #221670','S. c #322F42','T. c #5A5A5A','U. c #C1C1C1','V. c #B3B3B3','W. c #BCBB58','X. c #F0F049','Y. c #B5D49B','Z. c #3F97AC','`. c #2C907F',' + c #DF2474','.+ c #C33224','++ c #281A82','@+ c #22166E','#+ c #2E2B3D','$+ c #919191','%+ c #565656','&+ c #B0B0B0','*+ c #AEAEAE','=+ c #BDBC59','-+ c #F0F048',';+ c #B0D198','>+ c #3491A7',',+ c #DF2374','"+ c #C33223',')+ c #20156C','!+ c #292738','~+ c #545454','{+ c #AAAAAA',']+ c #B2B2B2','^+ c #B0D197','/+ c #20903E','(+ c #D92782','_+ c #DF2373',':+ c #C72F30','<+ c #271A82','[+ c #1E1464','}+ c #262432','|+ c #ADADAD','1+ c #ABABAB','2+ c #A6A6A6','3+ c #BDBD59','4+ c #F0EF48','5+ c #AFD196','6+ c #6A6559','7+ c #B23022','8+ c #595192','9+ c #444060','0+ c #2C2B2F','a+ c #606060','b+ c #5B5B5B','c+ c #BBBBBB','d+ c #BEBD5A','e+ c #F0EF47','f+ c #3391A7','g+ c #308E7F','h+ c #2A9446','i+ c #667666','j+ c #9D4D8E','k+ c #715582','l+ c #3B2A2F','m+ c #232121','n+ c #717171','o+ c #383838','p+ c #2C2C2C','q+ c #5C5C5C','r+ c #BEBEBE','s+ c #9D9D9D','t+ c #E5E447','u+ c #B2B18E','v+ c #766396','w+ c #8C688A','x+ c #98C5A4','y+ c #75A49B','z+ c #3A7683','A+ c #315760','B+ c #2A2F30','C+ c #282828','D+ c #2B2B2B','E+ c #2E2D2D','F+ c #4E4E4E','G+ c #555555','H+ c #777759','I+ c #696942','J+ c #9D5F76','K+ c #B03374','L+ c #984A71','M+ c #767575','N+ c #585C5D','O+ c #3E4547','P+ c #373838','Q+ c #3A3A3A','R+ c #8F8F8F','S+ c #8E8E8E','T+ c #131313','U+ c #666668','V+ c #575657','W+ c #686767','X+ c #5B5A5B','Y+ c #636363','Z+ c #BDBDBD','`+ c #9A9A9A',' @ c #727272','.@ c #ACACAC','+@ c #696868','@@ c #E7E7E7','#@ c #EEEEEE','$@ c #E9E9E9','%@ c #999999','&@ c #8A8A8A','*@ c #464646','=@ c #3B3B3B','-@ c #0A0A0A',';@ c #171717','>@ c #878787', ' ', ' ', ' . + ', ' @ # ', ' $ % ', ' & * = ', ' - ; > , ', ' " ) ! ~ { ] ^ ', ' / ( _ : < ; [ } | | 1 ', ' 2 3 / 4 5 6 7 8 9 0 a b ', ' c d [ e f g h 9 i j k l m n o m b ', ' p ~ q l r s t u v o w x i j r h y z A a 1 ', ' B C D E F y G H I J K z L 8 M N O P r r O Q ', ' " o R D E S T 7 U h V P W X m Y P Z ` .s .. ', ' < +.A R D E S @.V X #.8 r $.T %.&.*.=.-.u > ', ' - s +.o w K k 8 #.;.>.,.".).!.~.{.].^./.- > ', ' (.a _.+.$.:.l <.[.}.|.1.2.3.4.5.6.7.8.9.$ > ', ' . O J _.q _.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n.> ', ' o.#.O a p.m q.r.s.t.u.v.w.x.y.z.A.B.C.D.b > ', ' E.F.M O G.:.H.I.J.K.L.M.N.O.y.P.A.Q.R.S.d > ', ' T.t U.M V.:.W.X.Y.Z.`.M.N.O. +P..+++@+#+Q $+ ', ' %+&+t F.*+Y =+-+;+>+`.M.N.O.,+P."+++)+!+_ $+ ', ' ~+{+]+t {+Y =+-+^+>+`./+N.(+_+:+"+<+[+}+o.$+ ', ' , |+1+]+2+P 3+4+5+>+`./+6+(+,+P.7+8+9+0+a+$+ ', ' b+c+} 1+G y d+e+5+f+g+h+i+j+k+l+m+n+o+p+~ .. ', ' q+r+p.&+s+y d+t+u+v+w+x+y+z+A+B+C+D+E+F+#... ', ' G+v T c+f V H+I+J+K+L+M+N+O+P+Q+, R+&+1+C S+ ', ' T+b c+T 1+V U+V+W+X+q+Y+$ e Z+c+P `+*+..#.g ', ' T+ @G..@$.e +@/ 4 *+l @@#@$@U v %@&@; b+ ', ' p @2+o k 8 s $@0 $@K k s+. *@^ ', ' T+. 0 0 z :.U.|+~ =@-@ ', ' ;@) R+>@- *@ ', ' ', ' ', ' ', ' '); $version = "1.8beta"; $tvrssicon = Gtk2::Gdk::Pixbuf->new_from_xpm_data(@tvicon); $tvrss = Gtk2::Window->new; $tvrss->set_icon($tvrssicon); $tvrss->set_title("TV RSS $version"); $tvrss->set_border_width(2); $tvrss->set_default_size(580, 350); $tvrss->signal_connect(delete_event => \&quit ); $vbox = Gtk2::VBox->new(0, 6); $hbox = Gtk2::HBox->new(0, 6); $vpane = Gtk2::VPaned->new; $console_buf = Gtk2::TextBuffer->new; $console = Gtk2::TextView->new_with_buffer($console_buf); $console->set(editable => 0); $console->set_cursor_visible(0); $list = Gtk2::SimpleList->new('Title' => 'text', 'Released' => 'text', 'URL' => 'text'); $scroll = Gtk2::ScrolledWindow->new; $scroll->set_policy(qw/automatic automatic/); $scroll->add($list); $scroll4 = Gtk2::ScrolledWindow->new; $scroll4->set_policy(qw/automatic automatic/); $scroll4->add($console); $tooltips = Gtk2::Tooltips->new; $btn_refresh = Gtk2::Button->new_from_stock('gtk-refresh'); $btn_download = Gtk2::Button->new('Download'); $btn_options = Gtk2::Button->new_from_stock('gtk-preferences'); $btn_console = Gtk2::ToggleButton->new_with_label('Console'); $btn_quit = Gtk2::Button->new_from_stock('gtk-quit'); $btn_refresh->signal_connect(clicked => \&refresh ); $btn_download->signal_connect(clicked => \&download ); $btn_options->signal_connect(clicked => \&options ); $btn_quit->signal_connect(clicked => \&quit ); $tooltips->set_tip($btn_refresh, 'Refresh list of torrents'); $tooltips->set_tip($btn_download, 'Download selected torrent'); $tooltips->set_tip($btn_options, 'Options for TV RSS'); $tooltips->set_tip($btn_quit, 'Quit'); $tooltips->enable; $vpane->set_position(250); $vpane->add1($scroll); $vpane->add2($scroll4); $hbox->pack_start($btn_refresh, 0, 1, 0); $hbox->pack_start($btn_download, 0, 1, 0); $hbox->pack_start($btn_options, 0, 1, 0); $hbox->pack_start($btn_quit, 0, 1, 0); $vbox->pack_start($hbox, 0, 1, 0); $vbox->pack_start($vpane, 1, 1, 0); $tvrss->add($vbox); sub downloadtorrent { if (load_options()) { $urlshift = shift; $autoshift = shift; if ($dir !~ /^$/) { if (`ls $dir 2>&1` =~ /No such file or directory/) { console_text("$dir: No such file or directory\n"); } else { if ($run !~ /^$/) { if ($run == 1) { if ($client !~ /^$/) { $checkclient = $client; if ($checkclient =~ /.+ .+/) { $checkclient =~ s/ .+//; } if (`ls $checkclient 2>&1` =~ /No such file or directory/) { console_text("$checkclient: No such file or directory\n"); } else { $filename = $urlshift; $filename =~ s/.+\/+//g; $downloadtorrent = `wget --user-agent=TV_RSS_$version -nv -O $dir/$filename $urlshift 2>&1`; if ($downloadtorrent =~ /\[1\]/) { system("$client $dir/$filename >/dev/null 2>&1 &"); if ($autoshift == 1) { console_text("Auto downloaded & ran $client $dir/$filename\n"); } else { console_text("Downloaded & ran $client $dir/$filename\n"); } } else { console_text("'$urlshift' download failed\n"); } } } else { console_text("No BT client set\n"); } } } else { $filename = $urlshift; $filename =~ s/.+\/+//g; $downloadtorrent = `wget --user-agent=TV_RSS_$version -nv -O $dir/$filename $urlshift 2>&1`; if ($downloadtorrent =~ /\[1\]/) { console_text("Downloaded $filename to $dir\n"); } } } } else { console_text("No torrent directory set\n"); } } } sub download { $row = join(", ", $list->get_selected_indices); $selected = $list->{data}[$row][2]; $torrent = $selected; $torrent =~ s/.+\/+//; $torrent =~ s/\[.+\]//g; $torrent =~ s/\.torrent//g; $torrent =~ s/\.$//g; downloadtorrent($selected,0); $dupe = 0; open(DLED,"<$ENV{'HOME'}/.tvrss_dled"); while () { if ($_ =~ /$torrent/) { $dupe = 1; } } close(DLED); if ($dupe != 1) { open(DLED,">>$ENV{'HOME'}/.tvrss_dled"); print DLED $torrent . "\n"; close(DLED); } } sub options { $options = Gtk2::Dialog->new('Options', undef, 'modal', 'gtk-ok' => 'ok'); $options->set_icon($tvrssicon); $options->set_skip_taskbar_hint(1); $vbox = Gtk2::VBox->new(0, 6); $vbox2 = Gtk2::VBox->new(0, 6); $vbox3 = Gtk2::VBox->new(0, 6); $vbox4 = Gtk2::VBox->new(0, 6); $vbox5 = Gtk2::VBox->new(0, 6); $hbox = Gtk2::HBox->new(0, 6); $hbox2 = Gtk2::HBox->new(0, 6); $hbox3 = Gtk2::HBox->new(0, 6); $hbox4 = Gtk2::HBox->new(0, 6); $hbox5 = Gtk2::HBox->new(0, 6); $hbox6 = Gtk2::HBox->new(0, 6); $hbox7 = Gtk2::HBox->new(0, 6); $hbox77 = Gtk2::HBox->new(0, 6); $list2 = Gtk2::SimpleList->new('Reg Exps' => 'text'); $scroll2 = Gtk2::ScrolledWindow->new; $scroll2->set_policy(qw/automatic automatic/); $scroll2->add($list2); $entryreg = Gtk2::Entry->new; $entrydir = Gtk2::Entry->new; $entryclient = Gtk2::Entry->new; $entryrefresh = Gtk2::Entry->new_with_max_length(3); $help = Gtk2::Button->new('?'); $plus = Gtk2::Button->new('->'); $minus = Gtk2::Button->new('<-'); $downloaded = Gtk2::Button->new('_Downloaded'); $addrssurl = Gtk2::Button->new_from_stock('gtk-add'); #here code added $removerssurl = Gtk2::Button->new_from_stock('gtk-remove'); $dirpick = Gtk2::Button->new('..'); $clientpick = Gtk2::Button->new('..'); $chk_console = Gtk2::CheckButton->new('Console'); $chk_runbt = Gtk2::CheckButton->new('Run Client'); $chk_autodl = Gtk2::CheckButton->new('Auto Download'); $chk_autorf = Gtk2::CheckButton->new('Auto Refresh'); $optionmenu = Gtk2::OptionMenu->new; $feedlist = Gtk2::SimpleList->new('Title' => 'text', 'URL' => 'text'); $scroll_feeds = Gtk2::ScrolledWindow->new; $scroll_feeds->set_policy(qw/automatic automatic/); $scroll_feeds->add($feedlist); $feedlist->show; $scroll_feeds->show; $entryrefresh->set_size_request(25,20); if (load_options()) { $entrydir->set_text($dir); $chk_autodl->set_active($autodl); $chk_autorf->set_active($autorf); $entryrefresh->set_text($refreshtime); $chk_console->set_active($showconsole); $chk_runbt->set_active($run); $entryclient->set_text($client); $optionmenu->set_history($combohist); if ($regexps !~ /^$/) { $f = 0; @items2 = split(",", $regexps); for ($g = 0; $g < @items2; $g++) { @itemslist2 = ( @itemslist2, [ $items2[$f++] ], ); } @{$list2->{data}} = ( @itemslist2 ); @itemslist2 = (); } } $hbox->pack_start(Gtk2::Label->new('Torrents Dir:'), 0, 0, 0); $hbox->pack_start($entrydir, 1, 1, 0); $hbox->pack_start($dirpick, 0, 1, 0); $hbox2->pack_start($scroll_feeds, 1, 1, 0); $hbox3->pack_start($chk_console, 1, 1, 0); $hbox3->pack_start($chk_runbt, 1, 1, 0); $hbox3->pack_start($chk_autodl, 1, 1, 0); $hbox3->pack_start($chk_autorf, 1, 1, 0); $hbox3->pack_start($entryrefresh, 0, 0, 0); $hbox3->pack_start(Gtk2::Label->new('Mins'), 0, 0, 0); $hbox4->pack_start(Gtk2::Label->new('Client:'), 0, 0, 0); $hbox4->pack_start($entryclient, 1, 1, 0); $hbox4->pack_start($clientpick, 0, 1, 0); $hbox5->pack_start($vbox2, 0, 0, 0); $hbox5->pack_start($vbox3, 0, 0, 0); $hbox5->pack_start($vbox4, 1, 1, 0); $hbox6->pack_start(Gtk2::Label->new('/'), 0, 0, 0); $hbox6->pack_start($entryreg, 0, 0, 0); $hbox6->pack_start(Gtk2::Label->new('/'), 0, 0, 0); $hbox7->pack_start($downloaded, 0, 1, 0); $vbox->pack_start($hbox, 0, 0, 0); $vbox->pack_start($hbox2, 0, 0, 0); $vbox->pack_start($hbox3, 0, 0, 0); $vbox->pack_start($hbox4, 0, 0, 0); $vbox2->pack_start($hbox6, 0, 0, 0); $hbox77->pack_start($addrssurl, 0, 1, 0); $hbox77->pack_start($removerssurl, 0, 1, 0); $hbox77->show; $removerssurl->show; $vbox2->pack_start($hbox77, 0, 1, 0); $vbox2->pack_start($hbox7, 0, 0, 0); $vbox3->pack_start($plus, 0, 0, 0); $vbox3->pack_start($minus, 0, 0, 0); $vbox3->pack_start($help, 0, 0, 0); $vbox4->pack_start($scroll2, 1, 1, 0); $options->vbox->pack_start($vbox, 0, 1, 0); $options->vbox->pack_start($hbox5, 1, 1, 2); $dirpick->signal_connect(clicked => sub { $pick = Gtk2::FileSelection->new('Select Torrent Dir'); if ('ok' eq $pick->run) { $pickdir = $pick->get_filename; $entrydir->set_text($pickdir); $pick->destroy; } else { $pick->destroy; } }); $clientpick->signal_connect(clicked => sub { $pick = Gtk2::FileSelection->new('Select BT Client'); if ('ok' eq $pick->run) { $pickclient = $pick->get_filename; $entryclient->set_text($pickclient); $pick->destroy; } else { $pick->destroy; } }); $help->signal_connect(clicked => sub { regexphelp(); }); $addrssurl->signal_connect(clicked => sub {addtolist(); }); $removerssurl->signal_connect(clicked => sub { $row = join(", ", $feedlist->get_selected_indices); splice @{ $feedlist->{data} }, $row, 1; }); $plus->signal_connect(clicked => sub { $addreg = $entryreg->get_text; $addreg =~ s/\s+//g; $addreg =~ s/\,//g; push @{$list2->{data}}, [ $addreg ]; $entryreg->set_text(''); }); $minus->signal_connect(clicked => sub { $row = join(", ", $list2->get_selected_indices); $del = $list2->{data}[$row][0]; $entryreg->set_text($del); delete $list2->{data}[$row]; }); $downloaded->signal_connect(clicked => sub { downloaded(); }); $options->signal_connect(response => sub { shift; $response = shift; if ($response eq 'ok') { open(OPTIONS,">$ENV{'HOME'}/.tvrss") or die "Can't save options"; $regexpsdump = Dumper($list2->{data}); $regexpsdump =~ s/\s+//g; $regexpsdump =~ s/.+=//g; $regexpsdump =~ s/[\[\]\'\;]+//g; $refreshtime = $entryrefresh->get_text; $refreshtime =~ s/\D//g; print OPTIONS "dir=" . $entrydir->get_text . "\n"; print OPTIONS "combohist=" . $optionmenu->get_history . "\n"; print OPTIONS "console=" . $chk_console->get_active . "\n"; print OPTIONS "run=" . $chk_runbt->get_active . "\n"; print OPTIONS "autodownload=" . $chk_autodl->get_active . "\n"; print OPTIONS "autorefresh=" . $chk_autorf->get_active . "\n"; print OPTIONS "refreshtime=" . $refreshtime . "\n"; print OPTIONS "client=" . $entryclient->get_text . "\n"; print OPTIONS "regexps=" . $regexpsdump . "\n"; close(OPTIONS); save_urltofile(); if ($chk_console->get_active == 1) { $scroll4->show; } else { $scroll4->hide; } if ($chk_autorf->get_active !~ /^$/ && $refreshtime !~ /^$/) { if ($chk_autorf->get_active == 1 && $refreshtime != 0) { if (defined $timer) { Glib::Source->remove($timer); $timer = Glib::Timeout->add($refreshtime * 60 * 1000, \&refresh); } else { $timer = Glib::Timeout->add($refreshtime * 60 * 1000, \&refresh); } } } $options->hide_all; } else { $options->hide_all; } }); $options->grab_focus; $options->show_all; } sub downloaded { $dled = Gtk2::Dialog->new('Downloaded Torrents', undef, 'modal', 'gtk-ok' => 'ok'); $dled->set_skip_taskbar_hint(1); $dled->set_icon($tvrssicon); $dled->set_default_size(200,300); $vbox = Gtk2::VBox->new(0, 6); $hbox = Gtk2::HBox->new(0, 6); $list3 = Gtk2::SimpleList->new('Title' => 'text'); $scroll3 = Gtk2::ScrolledWindow->new; $scroll3->set_policy(qw/automatic automatic/); $scroll3->add($list3); $clearhistory = Gtk2::Button->new('_Clear History'); @{$list3->{data}} = (); @itemslist3 = (); open(OPTIONS,"<$ENV{'HOME'}/.tvrss_dled"); while () { $item3 = $_; chop($item3); @itemslist3 = ( @itemslist3, $item3 ); @{$list3->{data}} = ( @itemslist3 ); } close(OPTIONS); $vbox->pack_start($scroll3, 1, 1, 0); $vbox->pack_start($clearhistory, 0, 0, 0); $hbox->pack_start($vbox, 1, 1, 0); $dled->vbox->pack_start($hbox, 1, 1, 0); $clearhistory->signal_connect(clicked => sub { console_text("Cleared history file $ENV{'HOME'}/.tvrss_dled\n"); $checkforwipe = `which wipe 2>&1`; if ($checkforwipe =~ /\/.*\/wipe/) { `cd $ENV{'HOME'} && wipe -s .tvrss_dled`; } else { `rm -f ~/.tvrss_dled`; } @{$list3->{data}} = (); }); $dled->signal_connect(response => sub { shift; $response = shift; if ($response eq 'ok') { $dled->hide_all; } else { $dled->hide_all; } }); $dled->show_all; } sub regexphelp { $reghelp = Gtk2::Dialog->new('Reg Exp Helper', undef, 'modal', 'gtk-ok' => 'ok'); $reghelp->set_icon($tvrssicon); $reghelp->set_skip_taskbar_hint(1); $entrymatch = Gtk2::Entry->new; $entryregexp = Gtk2::Entry->new; $entrymatch->set_text('Show.S01E01.HDTV-GROUP'); $entryregexp->set_text('Show.+HDTV'); $checkreg = Gtk2::Button->new('Check'); $clearreg = Gtk2::Button->new('Clear'); $regstatus = Gtk2::Label->new(''); $vbox = Gtk2::VBox->new(0, 6); $hbox = Gtk2::HBox->new(0, 6); $hbox2 = Gtk2::HBox->new(0, 6); $hbox3 = Gtk2::HBox->new(0, 6); $hbox4 = Gtk2::HBox->new(0, 6); $vbox->pack_start(Gtk2::Label->new('Case insensitive. No spaces, Use .'), 0, 0, 0); $vbox->pack_start(Gtk2::Label->new('Examples: Show - Any Show'), 0, 0, 0); $vbox->pack_start(Gtk2::Label->new('Show.+(PDTV|XviD) - PDTV or XviD'), 0, 0, 0); $vbox->pack_start(Gtk2::Label->new('Show.+HDTV.+GROUP - HDTV, GROUP only'), 0, 0, 0); $vbox->pack_start(Gtk2::Label->new('Show.+VCD(?!.+GROUP) - Any VCD that isn\'t from GROUP'), 0, 0, 0); $hbox2->pack_start(Gtk2::Label->new('Match:'), 0, 0, 0); $hbox2->pack_start($entrymatch, 1, 1, 0); $hbox3->pack_start(Gtk2::Label->new('Reg Exp: /'), 0, 0, 0); $hbox3->pack_start($entryregexp, 1, 1, 0); $hbox3->pack_start(Gtk2::Label->new('/'), 0, 0, 0); $hbox4->pack_start($checkreg, 0, 0, 0); $hbox4->pack_start($clearreg, 0, 0, 0); $hbox4->pack_start($regstatus, 1, 1, 0); $reghelp->vbox->pack_start($vbox, 0, 1, 0); $reghelp->vbox->pack_start($hbox, 1, 0, 2); $reghelp->vbox->pack_start($hbox2, 1, 0, 2); $reghelp->vbox->pack_start($hbox3, 1, 0, 2); $reghelp->vbox->pack_start($hbox4, 1, 0, 2); $checkreg->signal_connect(clicked => sub { $regexp = $entryregexp->get_text; if ($entrymatch->get_text =~ /$regexp/xi) { $regstatus->set_text('Found Match'); } else { $regstatus->set_text('No Match'); } }); $clearreg->signal_connect(clicked => sub { $entrymatch->set_text(''); $entryregexp->set_text(''); }); $reghelp->signal_connect(response => sub { shift; $response = shift; if ($response eq 'ok') { $reghelp->hide_all; } else { $reghelp->hide_all; } }); $reghelp->show_all; } sub addtolist { $addurldialog = Gtk2::Dialog->new('Add new RSS feed', undef, 'modal', 'gtk-ok' => 'ok', 'gtk-cancel' => 'cancel'); $addurldialog->set_icon($tvrssicon); $addurldialog->set_skip_taskbar_hint(1); $entryrssurl = Gtk2::Entry->new; $entryrsstitle = Gtk2::Entry->new; $entryrssurl->set_text(''); $entryrsstitle->set_text(''); $clearurl = Gtk2::Button->new('Clear'); $regstatus = Gtk2::Label->new(''); $vbox = Gtk2::VBox->new(0, 6); $hbox = Gtk2::HBox->new(0, 6); $hbox2 = Gtk2::HBox->new(0, 6); $hbox3 = Gtk2::HBox->new(0, 6); $hbox4 = Gtk2::HBox->new(0, 6); $hbox5 = Gtk2::HBox->new(0, 6); $optionmenu = Gtk2::OptionMenu->new; $menu = Gtk2::Menu->new; $cust = Gtk2::MenuItem->new ("Custom Feed"); $eztv = Gtk2::MenuItem->new ("EZTV"); $ctv = Gtk2::MenuItem->new ("CentralTV"); $vtv = Gtk2::MenuItem->new ("VTV"); $cust->show; $eztv->show; $ctv->show; $vtv->show; $menu->append($cust); $menu->append($eztv); $menu->append($ctv); $menu->append($vtv); $optionmenu->set_menu($menu); $vbox->pack_start(Gtk2::Label->new('Please enter a feed URL and a title'), 0, 0, 0); $hbox2->pack_start(Gtk2::Label->new('URL:'), 0, 0, 0); $hbox2->pack_start($entryrssurl, 1, 1, 0); $hbox3->pack_start(Gtk2::Label->new('Title:'), 0, 0, 0); $hbox3->pack_start($entryrsstitle, 1, 1, 0); $hbox4->pack_start($clearurl, 0, 0, 0); $hbox5->pack_start($optionmenu, 0, 0, 0); $hbox4->pack_start($regstatus, 1, 1, 0); $addurldialog->vbox->pack_start($vbox, 0, 1, 0); $addurldialog->vbox->pack_start($hbox, 1, 0, 2); $addurldialog->vbox->pack_start($hbox2, 1, 0, 2); $addurldialog->vbox->pack_start($hbox3, 1, 0, 2); $addurldialog->vbox->pack_start($hbox5, 1, 0, 2); $addurldialog->vbox->pack_start($hbox4, 1, 0, 2); $clearurl->signal_connect(clicked => sub { $entryrssurl->set_text(''); $entryrsstitle->set_text(''); }); $eztv->signal_connect(activate => sub { $entryrssurl->set_text('http://tvrss.net/sources/eztv/'); $entryrsstitle->set_text('EZTV'); }); $ctv->signal_connect(activate => sub { $entryrssurl->set_text('http://tvrss.net/sources/ctv/'); $entryrsstitle->set_text('CentralTV'); }); $vtv->signal_connect(activate => sub { $entryrssurl->set_text('http://tvrss.net/sources/vtv/'); $entryrsstitle->set_text('VTV'); }); $cust->signal_connect(activate => sub { $entryrssurl->set_text('http://'); $entryrsstitle->set_text('Custom Feed'); }); $addurldialog->signal_connect(response => sub { shift; $response = shift; if ($response eq 'ok') { push @{$feedlist->{data}}, [ $entryrsstitle->get_text, $entryrssurl->get_text]; $addurldialog->hide_all; } else { $addurldialog->hide_all; } }); $addurldialog->show_all; } sub cycle_array { $array_row = scalar(@{$feedlist->{data}}); $array_col = 1; @rss_url_list = ''; for($current_row = 0; $current_row < $array_row; $current_row++) { push(@rss_url_list, $feedlist->{data}[$current_row][$array_col]); } } sub refresh { cycle_array(); if (load_options()) { @{$list->{data}} = (); @itemslist = (); foreach $url(@rss_url_list) { if ($url !~ /^$/) { $xml = `rm -f ~/.tvrss_xml && wget --user-agent=TV_RSS_$version -nv -O ~/.tvrss_xml $url 2>&1`; if ($xml =~ /\[1\]/) { $feed = XML::RAI->parsefile("$ENV{'HOME'}/.tvrss_xml"); $count = $feed->item_count(); console_text("RSS feed loaded $count item(s)\n"); foreach $item ( @{$feed->items} ) { $title = $item->title; $issued = $item->issued; $link = $item->link; @itemslist = ( @itemslist, [ $title, $issued, $link ], ); if ($autodl !~ /^$/) { if ($autodl == 1) { if ($regexps !~ /^$/) { @regexp = split(",", $regexps); for ($e = 0; $e < @regexp; $e++) { if ($link =~ /$regexp[$e]/xi) { if ($link =~ /\.torrent/i) { $torrent = sprintf("%s",$link); $torrent =~ s/.+\/+//; $torrent =~ s/\[.+\]//g; $torrent =~ s/\.torrent//g; $torrent =~ s/\.$//g; open(DLED,"<$ENV{'HOME'}/.tvrss_dled"); while () { if ($_ =~ /$torrent/) { goto dled; } } close(DLED); downloadtorrent($link,1); open(DLED,">>$ENV{'HOME'}/.tvrss_dled"); print DLED $torrent . "\n"; close(DLED); dled: } } } } } } } @{$list->{data}} = ( @itemslist ); } } } } 1; } sub init_timer { if (load_options()) { if ($autorf !~ /^$/ && $refreshtime !~ /^$/) { if ($autorf == 1 && $refreshtime != 0) { $timer = Glib::Timeout->add($refreshtime * 60 * 1000, \&refresh); } } } } sub load_options { open(OPTIONS,"<$ENV{'HOME'}/.tvrss") or 0; while () { if ($_ =~ /dir=/) { ($null,$dir) = split(/=/); chop($dir); } if ($_ =~ /url=/) { ($null,$url) = split(/=/); chop($url); } if ($_ =~ /autodownload=/) { ($null,$autodl) = split(/=/); chop($autodl); } if ($_ =~ /autorefresh=/) { ($null,$autorf) = split(/=/); chop($autorf); } if ($_ =~ /refreshtime=/) { ($null,$refreshtime) = split(/=/); chop($refreshtime); } if ($_ =~ /run=/) { ($null,$run) = split(/=/); chop($run); } if ($_ =~ /client=/) { ($null,$client) = split(/=/); chop($client); } if ($_ =~ /combohist=/) { ($null,$combohist) = split(/=/); chop($combohist); } if ($_ =~ /regexps=/) { ($null,$regexps) = split(/=/); chop($regexps); } if ($_ =~ /console=/) { ($null,$showconsole) = split(/=/); chop($showconsole); } } close(OPTIONS); open(URLOPTS,"<$ENV{ 'HOME' }/.tvrssurl") or 0; @data_from_dump = (); @{$feedlist->{data}} = (); foreach $temporary () { chomp($temporary); push(@data_from_dump, $temporary); } $line_lenght = scalar(@data_from_dump); for( $current_line = -2; $current_line < $line_lenght - 2; $current_line = $current_line + 2) { $data_line = $current_line + 2; $column_data = $data_line + 1; push @{$feedlist->{data}}, [$data_from_dump[$data_line], $data_from_dump[$column_data]]; } close(URLOPTS); 1; } sub window_options { open(WINOPTIONS,"<$ENV{'HOME'}/.tvrss_win"); while () { if ($_ =~ /size=/) { ($null,$size) = split(/=/); ($width,$height) = split(/,/, $size); $tvrss->set_default_size ($width, $height); } if ($_ =~ /position=/) { ($null,$position) = split(/=/); ($root_x,$root_y) = split(/,/, $position); $tvrss->move ($root_x, $root_y); } if ($_ =~ /paned_pos=/) { ($null,$pane_pos) = split(/=/); $vpane->set_position($pane_pos); } } close(OPTIONS); $vbox->show_all; if (load_options()) { if ($showconsole == 1) { } else { $scroll4->hide; } } $tvrss->show; } sub timestamp { ($sec,$min,$hour) = localtime(time); if (length($min) == 1) { $min = "0" . $min; } if (length($hour) == 1) { $hour = "0" . $hour; } if (length($sec) == 1) { $sec = "0" . $sec; } return "[" . $hour . ":" . $min . ":" . $sec . "]"; } sub console_text { $addto = shift; $existing = $console_buf->get_text($console_buf->get_start_iter, $console_buf->get_end_iter, 1); $console_buf->set_text($existing . timestamp() . " " . $addto); } sub save_urltofile { open(URLOPTS,">$ENV{ 'HOME' }/.tvrssurl") or die "Can't save the feeds"; $array_row = scalar(@{$feedlist->{data}}); $array_col = 1; for($current_row = 0; $current_row < $array_row; $current_row++) { print URLOPTS $feedlist->{data}[$current_row][0], "\n"; print URLOPTS $feedlist->{data}[$current_row][1], "\n"; } close(URLOPTS); } sub quit { open(WINOPTIONS,">$ENV{'HOME'}/.tvrss_win"); ($paned_pos) = $vpane->get_position; ($width,$height) = $tvrss->get_size; ($root_x,$root_y) = $tvrss->get_position; ($left,$top,$null,$null) = $tvrss->get_frame_dimensions; $root_x -= $left; $root_y -= $top; print WINOPTIONS "size=$width,$height\n"; print WINOPTIONS "position=$root_x,$root_y\n"; print WINOPTIONS "paned_pos=$paned_pos\n"; close(WINOPTIONS); if (`ls ~/.tvrss_xml 2>&1` !~ /No such file or directory/) { $checkforwipe = `which wipe 2>&1`; if ($checkforwipe =~ /\/.*\/wipe/) { `cd $ENV{'HOME'} && wipe -s .tvrss_xml`; } else { `rm -f ~/.tvrss_xml`; } } Gtk2->main_quit; } window_options(); console_text("TV RSS $version loaded\n"); init_timer(); refresh(); Gtk2->main;