Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace eval ::ioNiNJA {
- variable logPath "../logs"
- namespace export *
- }
- interp alias {} IsTrue {} string is true -strict
- interp alias {} IsFalse {} string is false -strict
- if {[catch {source "../scripts/ioNiNJA/ioNiNJA.cfg"} error]} {
- putlog -error $error
- return
- }
- if {[catch {source "../scripts/ioNiNJA/themes/$ioNJ(themefile)"} error]} {
- putlog -error $error
- return
- }
- if {[catch {package require http 2.7.1} error]} {
- putlog -error $error
- return
- }
- proc ::ioNiNJA::sfv_check {sfvfile} {global pwd ioNJ path
- set sfvdata [split [string tolower [readfile $sfvfile]] \n]
- set newsfv ""
- set m3u ""
- foreach line $sfvdata {
- if {[string index $line 0] != ";"} {
- if {[string length [lindex $line end]] == 8 && [llength $line] >= 2} {
- if {[lsearch -glob $newsfv "[lindex $line 0] *"] == "-1"} {
- lappend newsfv $line
- if {$ioNJ(create_missing_files)} {
- if {![regexp -nocase {\.mu3$|\.nfo$} [string trim [lrange $line 0 end-1]]]} {
- catch {set missingfile [open $path/[lrange $line 0 end-1]${ioNJ(missingtag)} w]} error
- catch {close $missingfile}
- }
- }
- }
- }
- }
- }
- set mp3s [lsearch -regexp -all -inline $newsfv {[^;](.+?\.mp3) ([0-9a-z]){8}}]
- #
- if {$ioNJ(create_m3u) && $mp3s != ""} {
- foreach mp $mp3s {
- append m3u "[lrange $mp 0 end-1]\n"
- }
- set m3uname "[file tail [file rootname $sfvfile]].m3u"
- writefile "$path/$m3uname" $m3u
- }
- #write new sfv file without comments
- if {$ioNJ(sfv_cleanup)} {
- writefile "$sfvfile" "[join $newsfv "\n"]"
- }
- #Type of release
- if {$mp3s != ""} {
- writechattr 12 "AUDIO"
- } elseif {[regexp -nocase {\.r[a0-9][r0-9]|\.0[0-9][0-9]} $newsfv]} {
- writechattr 12 "RAR"
- } elseif {[regexp -nocase $ioNJ(samples) $newsfv]} {
- writechattr 12 "VIDEO"
- } else {
- writechattr 12 "OTHER"
- }
- symlink_proc cd 1 ; symlink_proc sfv 0
- writechattr 35 $newsfv
- writechattr 13 [llength $newsfv]
- return
- }
- proc ::ioNiNJA::clean_nfo {nfofile} {
- set nfo [readfile $nfofile]
- set tempnfo ""
- regsub -all "\r\n\r\n" $nfo "\r\n" nfo
- foreach line [split $nfo \n] {
- lappend tempnfo "[string trimright $line]"
- }
- set temp [writefile $nfofile [join $tempnfo \n]]
- unset nfo
- unset tempnfo
- return
- }
- ########################
- # Symlink Proc
- ########################
- proc ::ioNiNJA::symlink_update {source} { global ioNJ pwd path
- set symtype 1
- foreach link [readchattr 240] {
- if {![file exists $link]} { continue }
- catch {vfs chattr "$link" 1} vfsdir
- iputs -nobuffer "Checking: $link"
- if {$vfsdir != ""} {
- set symtype 0
- } elseif {![catch {file link $link} templink]} {
- set symtype 1
- }
- if {$symtype} {
- catch {file delete -force -- $link}
- catch {file mkdir "[file dirname $link]"}
- catch {file link -symbolic "$link" "$source"} error
- } else {
- catch {file delete -force -- $link}
- catch {file mkdir "$link"}
- catch {vfs chattr "$link" 1 "$pwd"}
- catch {vfs flush "$link"}
- }
- }
- return
- }
- proc ::ioNiNJA::symlink_clean {} {global ioNJ
- foreach cleandir [split [string trim $ioNJ(cleanup_dirs)] \n] {
- set dirs [resolve pwd $cleandir]
- set nr 0
- while {[lindex $dirs $nr] != ""} {
- if {[catch {file link [lindex $dirs $nr]} templink]} {
- foreach dir [glob -nocomplain -type d -directory [lindex $dirs $nr] "*"] {
- lappend dirs $dir
- }
- }
- iputs -nobuffer "buffering: [file tail [lindex $dirs $nr]]"
- incr nr
- after 10
- }
- foreach dir $dirs {
- set delete 0
- if {$dir == "" || ( ![file exists $dir] )} { continue }
- catch {vfs chattr "$dir" 1} vfsdir
- iputs -nobuffer "checking: [file tail $dir]"
- if {$vfsdir != ""} {
- if {![file exists [resolve pwd $vfsdir]]} {
- set delete 1 }
- } elseif {![catch {file link $dir} templink]} {
- if {![file exists $templink]} {
- set delete 1
- }
- }
- if {$delete} {
- catch {file delete -force -- $dir} error
- set dir [file dirname $dir]
- while {[glob -nocomplain -directory $dir "*"] == ""} {
- catch {file delete -force -- $dir} error
- set dir [file dirname $dir]
- }
- }
- }
- }
- unset -nocomplain dirs
- }
- #######################
- ## Get Stats
- #######################
- proc ::ioNiNJA::get_stats {} {global pwd path uid gid
- set wkup "" ; set mnup "" ; set allup "" ; set dayup ""
- foreach uname [user list] {
- set user1 [resolve uid $uname]
- if {![userfile open $user1]} {
- if {![catch {set uf [userfile bin2ascii]}]} {
- regexp -nocase {wkup (.+?)\n} $uf -> userwkup
- lappend wkup "$user1 [Calculate_Stats $userwkup]"
- regexp -nocase {monthup (.+?)\n} $uf -> usermnup
- lappend mnup "$user1 [Calculate_Stats $usermnup]"
- regexp -nocase {allup (.+?)\n} $uf -> userallup
- lappend allup "$user1 [Calculate_Stats $userallup]"
- regexp -nocase {dayup (.+?)\n} $uf -> userdayup
- lappend dayup "$user1 [Calculate_Stats $userdayup]"
- }
- }
- }
- if {![userfile open [resolve uid $uid]]} {
- if {![catch {set uf [userfile bin2ascii]}]} {
- }
- }
- set wkup [lsort -decreasing -integer -index end "$wkup"]
- set mnup [lsort -decreasing -integer -index end "$mnup"]
- set allup [lsort -decreasing -integer -index end "$allup"]
- set dayup [lsort -decreasing -integer -index end "$dayup"]
- return [list $dayup $wkup $mnup $allup]
- }
- proc ::ioNiNJA::Calculate_Stats {tempstats} {
- set totalsize 0
- foreach {files size speed} $tempstats {
- if {$size == 0} { continue }
- set totalsize [format %.0f [expr $totalsize + ($size /1024.0)]]
- }
- return $totalsize
- }
- #######################
- ## DELETE DIR
- #######################
- proc ::ioNiNJA::delete_dir {delpwd delpath} {global ioNJ pwd path
- symlink_proc cd 0
- symlink_proc sfv 0
- symlink_proc nfo 0
- vfs write $delpath 0 0 744
- vfs flush $delpath
- set error 0
- set counter 0
- while {$error != "" && ( $counter != 50) } {
- catch {set temp [client kill virtualpath "$delpwd/*"]} temp
- catch {file delete -force -- "$delpath"} error
- incr counter
- after 200
- }
- return $error
- }
- proc ::ioNiNJA::get_mp3_information {mp3file} {global ioNJ args pwd path uid gid
- if {![file exists $mp3file]} { return }
- set mp3 [readchattr 25]
- set dir [lindex [file split $pwd] end]
- if {[regexp -nocase $ioNJ(notparent) $dir]} {
- set subdir 1
- set dir [lindex [file split $pwd] end-1]
- }
- if {![info exists uid]} {
- set uid 0
- set gid 0
- }
- set user [resolve uid $uid]
- set ugroup [resolve gid $gid]
- set fname [file tail $mp3file]
- set lame "NA"
- set lpreset "NA"
- set vbroldnew "NA"
- set fd [open $mp3file r]
- fconfigure $fd -encoding binary -translation binary -buffering full -buffersize 1000000
- set idx 1
- set offset 0
- set mp3header [read $fd 10]
- seek $fd -128 end
- set id3v1 [read $fd]
- seek $fd 0
- #GET THE iD3 TAG
- binary scan $id3v1 A3 id
- if {[string equal $id TAG]} {
- set genre 149
- binary scan $id3v1 A3A30A30A30A4A28ccc id title artist album year comment zero track genre
- if {$genre == "-1"} {
- set genre "Unknown"
- } elseif {$genre < 0 } {
- set genre [expr $genre + 256]
- set genre [lindex $ioNJ(genres) $genre]
- } else {
- set genre [lindex $ioNJ(genres) $genre]
- }
- if {$genre == ""} { set genre Unknown }
- } else {
- set title "Unknown" ; set artist "Unknown" ; set album "Unknown" ; set year "0000" ; set comment "Unknown" ; set zero 0 ; set track 0 ; set genre "Unknown"
- }
- #Get THE iD3v2 TAG
- binary scan $mp3header A3B8B8B8B32 tempid3 tempversion tempsubversion flags size
- if {[string match -nocase "id3" $tempid3]} {
- binary scan $mp3header A3B8B8B8B32 tempid3 tempversion tempsubversion flags size
- set id3v2 [bin2dec $tempversion]
- if {[string index $flags 4] != 0} {
- set offset [expr [bin2dec [string range $size 1 7][string range $size 9 15][string range $size 17 23][string range $size 25 31]]+20]
- } else {
- set offset [expr [bin2dec [string range $size 1 7][string range $size 9 15][string range $size 17 23][string range $size 25 31]]+10]
- }
- seek $fd 10
- set id3v2tag [read $fd $offset]
- if {$id3v2 >= "1"} {
- set num 0
- if { $id3v2 >= "3" } {
- set bscan A4B32
- set offset2 10
- set offset3 11
- } elseif {$id3v2 == "2"} {
- set bscan A3B24
- set offset2 6
- set offset3 7
- }
- while {$id3v2tag != ""} {
- binary scan $id3v2tag $bscan ID size
- set tempcrap [expr [bin2dec [string range $size 1 7][string range $size 9 15][string range $size 17 23][string range $size 25 31]]+$offset2]
- if {$tempcrap == $offset2} { break }
- set data [string range $id3v2tag $offset3 [expr $tempcrap-1]]
- set data [string trim [regsub -all -- {[^[:graph:] ]|ÿ|þ} $data {}]]
- switch -- $ID {
- TRCK { if {$track == ""} { set track [lindex [split $data /] 0] } }
- COMM { set comm [string range $data 4 end] }
- TIT2 { set title $data }
- TPE1 { set artist $data }
- TALB { set album $data }
- MCDI { set id3v2tag [string range $id3v2tag [expr 814 - $tempcrap] end] }
- TYER { if {$year == "0000" && [string is integer -strict $data] || ([string length $year] == 4)} { set year $data } }
- TCON {
- if {$genre == "Unknown"} { if {[regexp -nocase {\(([0-9]+)\)} $data -> genrenr]} { set genre [lindex $ioNJ(genres) $genrenr] } elseif {$data != ""} { set genre "$data" } }
- }
- TT2 { set title $data }
- TOA { set artist $data }
- TP1 { set artist $data }
- TRK { if {$track == ""} { set track [lindex [split $data /] 0] } }
- CM1 { set comm [string range $data 4 end] }
- TAL { set album $data }
- TYE { if {$year == "0000" && [string is integer -strict $data] || ([string length $year] == 4)} { set year $data } }
- TCO {
- if {$genre == "Unknown"} { if {[regexp -nocase {\(([0-9]+)\)} $data -> genrenr]} { set genre [lindex $ioNJ(genres) $genrenr] } elseif {$data != ""} { set genre "$data" } }
- }
- }
- set id3v2tag [string range $id3v2tag $tempcrap end]
- incr num
- }
- }
- }
- if {$year == "" || [string length $year] != 4} {
- if {![regexp -nocase {([0-9]{4})} $dir -> year]} {
- set year "0000"
- }
- }
- if {$title == ""} { set title "Unknown" }
- if {$album == ""} { set album "Unknown" }
- if {$artist == ""} { set artist "Unknown" }
- if {$ioNJ(strip_the)} { regsub -nocase {^the } $artist {} artist }
- regexp -nocase {(.+?) (feat|ft)} $artist -> artist crap
- set artist [string trim $artist]
- seek $fd $offset
- while { ![eof $fd] } {
- set head1 [read $fd 1]
- scan $head1 %c byte1
- if { ($byte1 & 0xFF) == 0xFF } {
- set head2 [read $fd 1]
- scan $head2 %c byte2
- if { ($byte2 & 0xE0) == 0xE0 } {
- set head3 [read $fd 2]
- scan $head3 %c%c byte3 byte4
- if { ([expr {($byte2 >> 3) & 0x3}] != 0x1) && ([expr {($byte2 >> 1) & 0x3}] != 0x0) && ((($byte3 >> 2) & 0x3) != 0x3) && ((($byte3 >> 4) & 0xF) != 0xf)} {
- set mpeghead "$head1$head2$head3"
- break
- }
- }
- }
- }
- if {![info exists mpeghead]} { close $fd ; putlog -error "$mp3file does not contain a mpeghead" ; return }
- binary scan $mpeghead B32 mp3head
- set Framesync [string range $mp3head 0 10]
- set MPEGAudioversion [string range $mp3head 11 12]
- set Layerdescription [string range $mp3head 13 14]
- set Protection [string index $mp3head 15]
- set Bitrate [string range $mp3head 16 19]
- set Samplingrate [string range $mp3head 20 21]
- set Padding [string index $mp3head 22]
- set Private [string index $mp3head 23]
- set Chanmode [string range $mp3head 24 25]
- set Modeextension [string range $mp3head 26 27]
- set Copyright [string index $mp3head 28]
- set Original [string index $mp3head 29]
- set Emphasis [string range $mp3head 30 31]
- switch -exact -- $MPEGAudioversion {
- 11 {set mpeg "1" ; set srateidx 0 }
- 10 {set mpeg "2" ; set srateidx 1 }
- 00 {set mpeg "2.5" ; set srateidx 2 }
- 01 {set mpeg "0" ; set srateidx 4 }
- }
- switch -exact -- $Layerdescription {
- 00 {set layer "0"}
- 01 {set layer "3"}
- 10 {set layer "2"}
- 11 {set layer "1"}
- }
- switch -exact -- $Protection {
- 0 {set protection "Yes"}
- 1 {set protection "No"}
- }
- switch -exact -- $mpeg.$layer {
- 1.1 { set bridx 0 }
- 1.2 { set bridx 1 }
- 1.3 { set bridx 2 }
- 2.1 { set bridx 3 }
- 2.2 { set bridx 4 }
- 2.3 { set bridx 4 }
- }
- set ioNJ(br.0000) {free free free free free }
- set ioNJ(br.0001) {32 32 32 32 8}
- set ioNJ(br.0010) {64 48 40 48 16}
- set ioNJ(br.0011) {96 56 48 56 24}
- set ioNJ(br.0100) {128 64 56 64 32}
- set ioNJ(br.0101) {160 80 64 80 40}
- set ioNJ(br.0110) {192 96 80 96 48}
- set ioNJ(br.0111) {224 112 96 112 56}
- set ioNJ(br.1000) {256 128 112 128 64}
- set ioNJ(br.1001) {288 160 128 144 80}
- set ioNJ(br.1010) {320 192 160 160 96}
- set ioNJ(br.1011) {352 224 192 176 112}
- set ioNJ(br.1100) {384 256 224 192 128}
- set ioNJ(br.1101) {416 320 256 224 144}
- set ioNJ(br.1110) {448 384 320 256 160}
- set ioNJ(br.1111) {bad bad bad bad bad}
- if {![info exists bridx]} { return }
- set bitrate "[lindex $ioNJ(br.$Bitrate) $bridx]"
- switch -exact -- $Samplingrate {
- 00 {set srate {"44100" "22050" "11025"}}
- 01 {set srate {"48000" "24000" "12000"}}
- 10 {set srate {"32000" "16000" "8000"}}
- 11 {set srate {Unknown Unknown Unknown}}
- }
- set srate [lindex $srate $srateidx]
- switch -exact -- $Chanmode {
- 00 {set channelmode Stereo}
- 01 {set channelmode "Joint Stereo"}
- 10 {set channelmode "Dual channel"}
- 11 {set channelmode Mono}
- }
- if {![info exists mpeg]} { putlog -error "$mp3file dmpeg not found in file" ; return }
- if {$layer > 3} { putlog -error "$mp3file reports mpeglayer $layer" ; return}
- set vbr 0
- if {$mpeg >= 2} {
- if {$channelmode == "Mono"} { set lamestart "13" } else { set lamestart "21" }
- } elseif {$mpeg == 1} {
- if {$channelmode == "Mono"} { set lamestart "21" } else { set lamestart "36" }
- }
- seek $fd [expr $offset + $lamestart]
- if { [read $fd 4] == "Xing" } {
- set vbr 1
- set xingFrames 0
- set xingBytes 0
- if {[binary scan [read $fd 4] I xingHeadFlags] != 1} {
- break
- }
- if {[binary scan [read $fd 4] I xingFrames] != 1} {
- break
- }
- if {[binary scan [read $fd 4] I xingBytes] != 1} {
- break
- }
- if { ($xingFrames > 0) && ($xingBytes > 0) && ($xingHeadFlags > 3) } {
- set bitrate [expr {(($xingBytes / $xingFrames) * $srate) / ($mpeg == 1 ? 144000 : 72000)}]
- }
- }
- if {$vbr} {
- #find out if it's old or new vbr
- seek $fd [expr $offset + 165]
- set vbrver [read $fd 1]
- set vbrver [scan $vbrver %c]
- switch -- $vbrver {
- 2 {set vbroldnew "ABR"} ; #abr
- 3 {set vbroldnew "VBR-OLD"} ; #vbr old / vbr rh
- 4 {set vbroldnew "VBR-NEW"} ; #VBR-MTRH
- 5 {set vbroldnew "VBR-NEW"} ; #VBR-MT
- }
- seek $fd [expr $offset + 155]
- set vbrquality [read $fd 1] ; # vbr quality setting
- set vbrquality [scan $vbrquality %c]
- seek $fd [expr $offset + 156]
- set lametemp [read $fd 10]
- binary scan $lametemp A9B8 Lame subrev
- set subver [bin2dec [string range $subrev 0 3]]
- set revision [bin2dec [string range $subrev 4 7]]
- set lame [string trim [string range $lametemp 0 8]]
- set sublame [scan [string index $lametemp 9] %c]
- seek $fd [expr $offset + 182]
- set preset [read $fd 2]
- binary scan $preset B16 temp
- set lamepreset [bin2dec $temp]
- if {[string index $lame end] == "."} {
- set lame "$lame$revision"
- }
- switch -- $lamepreset {
- 1000 {set lpreset "APR"}
- 1001 {set lpreset "APS"}
- 1002 {set lpreset "APE"}
- 1003 {set lpreset "API"}
- 1004 {set lpreset "FAPS"}
- 1005 {set lpreset "FAPE"}
- 1006 {set lpreset "APM"}
- 1007 {set lpreset "FAPM"}
- 320 {set lpreset "INSANE"}
- 410 {set lpreset "V9"}
- 420 {set lpreset "V8"}
- 430 {set lpreset "V7"}
- 440 {set lpreset "V6"}
- 450 {set lpreset "V5"}
- 460 {set lpreset "V4"}
- 470 {set lpreset "V3"}
- 480 {set lpreset "V2"}
- 490 {set lpreset "V1"}
- 500 {set lpreset "V0"}
- }
- }
- if {$Bitrate != 0000} {
- set duration [expr {int([file size $mp3file]*8 / double(1000*$bitrate))}]
- } else {
- set duration 0
- }
- close $fd
- if {$Original == 0} { set mp3original NO } else { set mp3original Yes }
- if {$Padding == 0} { set mp3padding NO } else { set mp3padding Yes }
- if {$vbr == 0} { set mp3vbr CBR } else { set mp3vbr VBR }
- set mp3info [list $artist $album $title $bitrate $mpeg $layer $channelmode $genre $year $srate $lame $lpreset $mp3original $mp3padding $duration $track $mp3vbr $vbroldnew]
- regsub -all {[^[:graph:] ]} $mp3info {} mp3info
- writechattr 25 $mp3info
- if {$mp3 == ""} {
- if {[regexp $ioNJ(mp3_path_check) $pwd] && $ioNJ(mp3_path_check) != "" } {
- #mp3 ban report or del
- if {$ioNJ(audio_year_check) && ![regexp $ioNJ(allowed_years) $year]} {
- if {[string match $ioNJ(del_banned_release_path) $pwd] && $ioNJ(del_banned_release_path) != ""} {
- output "$ioNJ(zipscript_header)$ioNJ(zipscript_mp3_del_year)$ioNJ(zipscript_footer_skip)"
- delete_dir "$pwd" "$path"
- return
- }
- if {$ioNJ(audio_year_warn)} {
- put_log "BADYEAR: [list $pwd $dir $user $ugroup $fname $year]"
- }
- }
- #check year and take action
- if {$ioNJ(audio_genre_check) == 1 && ![regexp -nocase $ioNJ(allowed_genres) $genre] && $ioNJ(allowed_genres) != ""} {
- if {[regexp -nocase $ioNJ(del_banned_release_path) $pwd] && $ioNJ(del_banned_release_path) != ""} {
- output "$ioNJ(zipscript_header)$ioNJ(zipscript_mp3_alo_genre)$ioNJ(zipscript_footer_skip)"
- delete_dir "$pwd" "$path"
- return
- }
- if {$ioNJ(audio_genre_warn)} {
- put_log "BADGENRE: [list $pwd $dir $user $ugroup $fname $genre]"
- }
- } elseif {$ioNJ(audio_genre_check) == 2 && [regexp -nocase $ioNJ(banned_genres) $genre] && $ioNJ(banned_genres) != ""} {
- if {$ioNJ(del_banned_release_path) != "" && [regexp -nocase $ioNJ(del_banned_release_path) $pwd]} {
- output "$ioNJ(zipscript_header)$ioNJ(zipscript_mp3_ban_genre)$ioNJ(zipscript_footer_skip)"
- delete_dir "$pwd" "$path"
- return
- }
- if {$ioNJ(audio_genre_warn)} {
- put_log "BADGENRE: [list $pwd $dir $user $ugroup $fname $genre]"
- }
- }
- }
- }
- return
- }
- #######################
- ## Mp3 Genres
- #######################
- set ioNJ(genres) {
- "Blues" "Classic Rock" "Country" "Dance"
- "Disco" "Funk" "Grunge" "Hip-Hop"
- "Jazz" "Metal" "New Age" "Oldies"
- "Other" "Pop" "R&B" "Rap"
- "Reggae" "Rock" "Techno" "Industrial"
- "Alternative" "Ska" "Death Metal" "Pranks"
- "Soundtrack" "Euro-Techno" "Ambient" "Trip-Hop"
- "Vocal" "Jazz+Funk" "Fusion" "Trance"
- "Classical" "Instrumental" "Acid" "House"
- "Game" "Sound Clip" "Gospel" "Noise"
- "Alt. Rock" "Bass" "Soul" "Punk"
- "Space" "Meditative" "Instrumental Pop" "Instrumental Rock"
- "Ethnic" "Gothic" "Darkwave" "Techno-Industrial"
- "Electronic" "Pop-Folk" "Eurodance" "Dream"
- "Southern Rock" "Comedy" "Cult" "Gangsta Rap"
- "Top 40" "Christian Rap" "Pop Funk" "Jungle"
- "Native American" "Cabaret" "New Wave" "Psychedelic"
- "Rave" "Showtunes" "Trailer" "Lo-Fi"
- "Tribal" "Acid Punk" "Acid Jazz" "Polka"
- "Retro" "Musical" "Rock & Roll" "Hard Rock"
- "Folk" "Folk Rock" "National Folk" "Swing"
- "Fast-Fusion" "Bebob" "Latin" "Revival"
- "Celtic" "Bluegrass" "Avantgarde" "Gothic Rock"
- "Progressive Rock" "Psychedelic Rock" "Symphonic Rock" "Slow Rock"
- "Big Band" "Chorus" "Easy Listening" "Acoustic"
- "Humour" "Speech" "Chanson" "Opera"
- "Chamber Music" "Sonata" "Symphony" "Booty Bass"
- "Primus" "Porn Groove" "Satire" "Slow Jam"
- "Club" "Tango" "Samba" "Folklore"
- "Ballad" "Power Ballad" "Rhythmic Soul" "Freestyle"
- "Duet" "Punk Rock" "Drum Solo" "A Cappella"
- "Euro-House" "Dance Hall" "Goa" "Drum & Bass"
- "Club-House" "Hardcore" "Terror" "Indie"
- "BritPop" "Negerpunk" "Polsk Punk" "Beat"
- "Christian Gangsta Rap" "Heavy Metal" "Black Metal" "Crossover"
- "Contemporary Christian" "Christian Rock" "Merengue" "Salsa"
- "Thrash Metal" "Anime" "JPop" "Synthpop"
- "Unknown"
- }
- #######################
- ## Binary To Decimal
- #######################
- proc ::ioNiNJA::bin2dec {binary} {
- set decimal 0
- for {set i 0} {$i < [string length $binary]} {incr i} {
- set next [string index $binary end-$i]
- set decimal [expr ($next << $i) | $decimal]
- }
- return $decimal
- }
- #######################
- ### Get Total Files From zipfile and extract nfo
- #######################
- proc ::ioNiNJA::get_zip_info {zipfile} {global path pwd
- if {![file exists $path/file_id.diz] || [file size "$path/file_id.diz"] == 0} {
- catch {set inzip [exec ../scripts/ioNiNJA/MiSC/UNZIP32.exe -qql $zipfile]} inzip
- foreach {Length Date Time Name} $inzip {
- if {[regexp -nocase {file_id\.diz$} $Name]} {
- catch {set temp [exec ../scripts/ioNiNJA/MiSC/UNZIP32.exe -Cqqp $zipfile $Name > $path/$Name]} temp
- vfs chattr "$path" 10 $Name
- }
- }
- symlink_proc cd 1
- }
- if {![file exists "$path/file_id.diz"]} {
- return
- } else {
- set diz "$path/file_id.diz"
- }
- if {[file size "$path/file_id.diz"] == 0} {
- catch {file delete -force "$path/file_id.diz"}
- return
- }
- regsub -all -nocase {x|o|\*} [readfile $diz] 0 diz
- regsub -all -nocase {[0-9]{1,4}/[0-9]{1,4}/[0-9]{1,4}} $diz "" diz
- set dizinfo [regexp {[^/0-9]([0-9]{1,3})(?:/|/\n)([0-9]{1,3})(?:[^/0-9]|$)} $diz -> file_nr total_files]
- if {[info exists total_files]} {
- scan $total_files %d total_files
- set total_files [format %.0f $total_files]
- catch {vfs chattr "$path" 13 $total_files}
- return
- } else {
- catch {file delete -force "$path/file_id.diz"}
- return
- }
- }
- #######################
- ### Get duration from timestamp
- #######################
- proc ::ioNiNJA::duration { secs } {
- if {![string is integer -strict $secs]} { return "0s" }
- set timeatoms [ list ]
- if { [ catch {
- foreach div { 86400 3600 60 1 } \
- mod { 0 24 60 60 } \
- name { d h m s } {
- set n [ expr {$secs / $div} ]
- if { $mod > 0 } { set n [ expr {$n % $mod} ] }
- if { $n > 1 } {
- lappend timeatoms "$n${name}"
- } elseif { $n == 1 } {
- lappend timeatoms "$n$name"
- }
- }
- } err ] } {
- return -code error "duration: $err"
- }
- return [ join $timeatoms ]
- }
- #######################
- ###Get userinfo
- #######################
- proc ::ioNiNJA::get_uinfo {user type} {
- if {[userfile open $user] == 0} {
- if {[set ufile [userfile bin2ascii]] != ""} {
- foreach info [split $ufile \n] {
- if {[string match -nocase $type [lindex $info 0]]} {
- return [lrange $info 1 end]
- }
- }
- }
- }
- return ""
- }
- #######################
- ### String map crappy html codes
- #######################
- proc ::ioNiNJA::htmlcodes {tempfile} {
- set mapfile [string map {& & " "   " "   " " ¡ ¡ ¡ ¡ ¡ ¡ ¢ ¢ ¢ ¢ ¢ ¢ £ £ £ £ £ £ ¤ ¤ ¤ ¤ ¤ ¤ ¥ ¥ ¥ ¥ ¥ ¥ ¦ ¦ ¦ ¦ ¦ ¦ § § § § § § ¨ ¨ ¨ ¨ ¨ ¨ © © © © © © ª ª ª ª ª ª « « « « « « ¬ ¬ ¬ ¬ ¬ ¬ ­ ­ ­ ® ® ® ® ® ® ¯ ¯ ¯ ¯ ¯ ¯ ° ° ° ° ° ° ± ± ± ± ± ± ² ² ² ² ² ² ³ ³ ³ ³ ³ ³ ´ ´ ´ ´ ´ ´ µ µ µ µ µ µ ¶ ¶ ¶ ¶ ¶ ¶ · · · · · · ¸ ¸ ¸ ¸ ¸ ¸ ¹ ¹ ¹ ¹ ¹ ¹ º º º º º º » » » » » » ¼ ¼ ¼ ¼ ¼ ¼ ½ ½ ½ ½ ½ ½ ¾ ¾ ¾ ¾ ¾ ¾ ¿ ¿ ¿ ¿ ¿ ¿ À À À À À À Á Á Á Á Á Á Â Â Â Â Â Â Ã Ã Ã Ã Ã Ã Ä Ä Ä Ä Ä Ä Å Å Å Å Å Å Æ Æ Æ Æ Æ Æ Ç Ç Ç Ç Ç Ç È È È È È È É É É É É É Ê Ê Ê Ê Ê Ê Ë Ë Ë Ë Ë Ë Ì Ì Ì Ì Ì Ì Í Í Í Í Í Í Î Î Î Î Î Î Ï Ï Ï Ï Ï Ï Ð Ð Ð Ð Ð Ð Ñ Ñ Ñ Ñ Ñ Ñ Ò Ò Ò Ò Ò Ò Ó Ó Ó Ó Ó Ó Ô Ô Ô Ô Ô Ô Õ Õ Õ Õ Õ Õ Ö Ö Ö Ö Ö Ö × × × × × × Ø Ø Ø Ø Ø Ø Ù Ù Ù Ù Ù Ù Ú Ú Ú Ú Ú Ú Û Ú Û Û Û Û Ü Ü Ü Ü Ü Ü Ý Ý Ý Ý Ý Ý Þ Þ Þ Þ Þ Þ ß ß ß ß ß ß à à à à à à á á á á á á â â â â â â ã ã ã ã ã ã ä ä ä ä ä ä å å å å å å æ æ æ æ æ æ ç ç ç ç ç ç è è è è è è é é é é é é ê ê ê ê ê ê ë ë ë ë ë ë ì ì ì ì ì ì í í í í í í î î î î î î ï ï ï ï ï ï ð ð ð ð ð ð ñ ñ ñ ñ ñ ñ ò ò ò ò ò ò ó ó ó ó ó ó ô ô ô ô ô ô õ õ õ õ õ õ ö ö ö ö ö ö ÷ ÷ ÷ ÷ ÷ ÷ ø ø ø ø ø ø ù ù ù ù ù ù ú ú ú ú ú ú û û û û û û ü ü ü ü ü ü ý ý ý ý ý ý þ þ þ þ þ þ ÿ ÿ ÿ ÿ ÿ ÿ } $tempfile]
- set mapfile [string map {" ' ' '   " " ' ' " ' & & [ ( \ / ] ) { ( } ) ¡ ¡ ¢ ¢ £ £ ¤ ¤ ¥ ¥ ¦ ¦ § § ¨ ¨ © © ª ª « « ¬ ¬ ­ ® ® } $mapfile]
- set mapfile [string map {¯ ¯ ° ° ± ± ² ² ³ ³ ´ ´ µ µ ¶ ¶ · · ¸ ¸ ¹ ¹ º º » » ¼ ¼ ½ ½ ¾ ¾ ¿ ¿ À À Á Á Â Â } $mapfile]
- set mapfile [string map {Ã Ã Ä Ä Å Å Æ Æ Ç Ç È È É É Ê Ê Ë Ë Ì Ì Í Í Î Î Ï Ï Ð Ð Ñ Ñ Ò Ò Ó Ó Ô Ô Õ Õ Ö Ö } $mapfile]
- set mapfile [string map {× × Ø Ø Ù Ù Ú Ú Û Û Ü Ü Ý Ý Þ Þ ß ß à à á á â â ã ã ä ä å å æ æ ç ç è è é é ê ê } $mapfile]
- set mapfile [string map {" ' & "And" ë ë ì ì í í î î ï ï ð ð ñ ñ ò ò ó ó ô ô õ õ ö ö ÷ ÷ ø ø ù ù ú ú û û ü ü ý ý þ þ } $mapfile]
- return $mapfile
- }
- #######################
- # Sorting
- #######################
- proc ::ioNiNJA::sorting {symtype linkto item pwd} {global ioNJ
- set linkto [file normalize $linkto]
- set item [file normalize $item]
- set item [string map [get_time [clock seconds]] $item]
- if {[file exists $item]} {
- if {![catch {file link $item} templink]} {
- set templink [file normalize $templink]
- if {![file exists $templink] || ( [string match -nocase $templink $linkto] )} {
- catch {file delete -force -- $item} error
- } elseif {[file tail $templink] == [file tail $linkto] && ( $templink != $linkto )} {
- set item "${item}.dupe"
- }
- } else {
- catch {file delete -force -- $item} error
- }
- }
- if {[file exists $item]} {
- set i 0
- while {[file exists "${item} (${i})"] && $i != 100} {
- incr i
- }
- set item "${item} (${i})"
- }
- if {!$symtype} {
- catch {file delete -force -- $item}
- catch {file mkdir "$item"}
- catch {vfs chattr "$item" 1 "$pwd"}
- catch {vfs flush "$item"}
- } else {
- catch {file delete -force -- $item}
- catch {file mkdir "[file dirname $item]"}
- catch {file link -symbolic "$item" "$linkto"} error
- }
- set symlinks [readchattr 240]
- lappend symlinks $item
- writechattr 240 $symlinks
- return
- }
- #######################
- ## Get URL
- #######################
- proc ::ioNiNJA::get_url_long_timeout {url} {
- if {[regexp -nocase { } [string trim $url]]} { return "" }
- set tempcode ""
- catch {
- set url_agent "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1"
- set url_page [::http::config -useragent $url_agent]
- set token [::http::geturl "$url" -timeout 600000]
- set i 0
- while {[set tempcode [::http::data $token]] == "" && $i != 5} {
- http::cleanup $token
- http::Finish $token
- set token [::http::geturl "$url" -timeout 600000]
- incr i
- }
- http::cleanup $token
- }
- return $tempcode
- }
- proc ::ioNiNJA::get_url2 {url} {
- if {[regexp -nocase { } [string trim $url]]} { return "" }
- set tempcode ""
- catch {
- set url_agent "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1"
- set url_page [::http::config -useragent $url_agent]
- set token [::http::geturl "$url" -timeout 60000]
- if {![info exists token]} { set token [::http::geturl "$url" -timeout 60000] }
- set i 0
- while {[set tempcode [string trim [::http::data $token]]] == "" && $i != 5} {
- http::cleanup $token
- http::Finish $token
- set token [::http::geturl "$url" -timeout 60000]
- incr i
- }
- http::cleanup $token
- }
- return $tempcode
- }
- proc ::ioNiNJA::get_url {url} {
- if {[regexp -nocase { } [string trim $url]]} { return "" }
- set tempcode ""
- catch {
- set url_agent "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1"
- set url_page [::http::config -useragent $url_agent]
- set token [::http::geturl "$url" -timeout 3000]
- if {![info exists token]} { set token [::http::geturl "$url" -timeout 3000] }
- set i 0
- while {[set tempcode [::http::data $token]] == "" && $i != 5} {
- http::cleanup $token
- http::Finish $token
- set token [::http::geturl "$url" -timeout 3000]
- incr i
- }
- set tempcode [htmlcodes $tempcode]
- http::cleanup $token
- }
- return $tempcode
- }
- #######################
- ## Get GrpName From Rel
- #######################
- proc ::ioNiNJA::get_grpname {release} {global ioNJ
- if {[regexp {\-} $release]} {
- set temps [split [string trim $ioNJ(force_groupnames)] \n]
- if {$temps != ""} {
- foreach temp $temps {
- lassign $temp regex grp
- if {[regexp -nocase $regex $release]} { return $grp }
- }
- }
- if {[lindex [split $release -] end] != $release} { return [lindex [split $release -] end]}
- }
- return "Unknown"
- }
- #######################
- ## Make inc symlinks
- #######################
- proc ::ioNiNJA::symlink_proc {type action} { global ioNJ pwd path
- set dir [lindex [file split $path] end]
- set parent [lindex [file split $path] end-1]
- set rdir [file dirname $path]
- set type2 ""
- if {[regexp -nocase "$ioNJ(notparent)" "$dir"]} {
- set rdir [file dirname $rdir]
- set type2 cd
- }
- switch -- $type {
- sfv {
- if {$type2 == "cd"} {
- set directory $ioNJ(incomplete_indicator_cd_sfv)
- } else {
- set directory $ioNJ(incomplete_indicator_sfv)
- }
- }
- nfo {
- if {$type2 == "cd"} {
- set dir $parent
- }
- set directory $ioNJ(incomplete_indicator_nfo)
- }
- sample {
- if {$type2 == "cd"} {
- set dir $parent
- }
- set directory $ioNJ(incomplete_indicator_sample)
- }
- cd {
- if {$type2 == "cd"} {
- set directory $ioNJ(incomplete_indicator_cd)
- } else {
- set directory $ioNJ(incomplete_indicator)
- }
- }
- }
- set dir [string map [list %di $dir %pa $parent] $directory]
- if {$action == 1} {
- catch {file mkdir "$rdir/$dir"}
- catch {vfs chattr "$rdir/$dir" 1 "$pwd"}
- catch {vfs flush $path }
- if {$ioNJ(sym_inc_dir) != "" && [file exists $ioNJ(sym_inc_dir)]} {
- if {![regexp -nocase $ioNJ(group_dirs) $pwd]} {
- catch {file mkdir "$ioNJ(sym_inc_dir)/$dir"}
- catch {vfs chattr "$ioNJ(sym_inc_dir)/$dir" 1 "$pwd"}
- catch {vfs flush $ioNJ(sym_inc_dir)}
- }
- }
- } else {
- catch {file delete -force "$rdir/$dir"}
- catch {vfs flush $path}
- if {$ioNJ(sym_inc_dir) != "" && ![regexp -nocase $ioNJ(group_dirs) $pwd]} {
- catch {file delete -force "$ioNJ(sym_inc_dir)/$dir"}
- catch {vfs flush $ioNJ(sym_inc_dir)}
- }
- }
- return
- }
- #######################
- ## Get Sammple Info
- #######################
- proc ::ioNiNJA::getsample {sample} { global path pwd ioNJ uid gid args
- set samplerelease [lindex [file split $pwd] end-1]
- set samplemessage "\n"
- catch {exec ../scripts/ioNiNJA/misc/media.exe $sample} temp
- if {$temp == ""} { return ""}
- set audiostreams 0
- set textstreams 0
- set type 0 ; set g_movie_name "N/A" ; set w_writelib "N/A" ; set v_chroma "N/A" ; set v_resolution "N/A" ; set g_performer "N/A" ; set g_format "N/A" ; set g_bitrate "N/A" ; set g_writeapp "N/A" ; set g_writelib "N/A" ; set a_codec "N/A" ; set a_codec_prof "N/A" ; set a_bitrate "N/A" ; set a_bitrate_mode "N/A" ; set a_chans "N/A" ; set a_srate "N/A" ; set a_WriteLib "N/A" ; set a_res "N/A" ; set a_chanpos "N/A" ; set v_codec_info "N/A" ; set v_codec_family "N/A" ; set v_codec_pack "N/A" ; set v_codec_bvop "N/A" ; set v_codec_qpel "N/A" ; set v_codec_gmc "N/A" ; set v_codec_matrix "N/A" ; set v_codec "N/A" ; set v_width "N/A" ; set v_height "N/A" ; set v_ar "N/A" ; set v_br "N/A" ; set v_fr "N/A" ; set v_standard "N/A" ; set v_interlace "N/A"
- set samplemessage $ioNJ(sample_head)
- foreach line [split $temp \n] {
- if {$line == ""} { continue }
- if {[string match "General #*" $line] || ( [regexp -nocase {(^General$)} $line] ) } {
- if {[lindex $line 1] == "#0" || ([regexp -nocase {(^General$)} $line]) } {
- set type g
- } else {
- set type 0
- }
- } elseif {[string match "Video #*" $line] || ( [regexp -nocase {(^Video$)} $line] ) } {
- if {[lindex $line 1] == "#1" || ([regexp -nocase {(^Video$)} $line])} {
- append samplemessage $ioNJ(sample_video_head)
- set type v
- } else {
- set type 0
- }
- } elseif {[string match "Audio #*" $line] || ([regexp -nocase {(^Audio$)} $line]) } {
- incr audiostreams
- if {[lindex $line 1] == "#1" || ([regexp -nocase {(^Audio$)} $line]) } {
- append samplemessage "$ioNJ(sample_audio_head)"
- set type a
- } else {
- set type 0
- }
- }
- if {[string match -nocase "Text #*" $line]} { set type 0 ; incr textstreams }
- set line [split $line :]
- set first [string trim [lindex $line 0]]
- set second [string trim [join [lrange $line 1 end]]]
- if {$type == "g"} {
- switch -- $first {
- "Copyright" { set g_movie_cr $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_copyright) $second]}
- "Movie name" { set g_movie_name $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_moviename) $second]}
- "Performer" { set g_performer $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_performer) $second]}
- "Format" { set g_format $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_format) $second]}
- "Bit rate" { set g_bitrate $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_bitrate) $second]}
- "Writing application" { set g_writeapp $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_writeapp) $second]}
- "Writing library" { set g_writelib $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_writelib) $second]}
- }
- }
- if {$type == "a"} {
- switch -- $first {
- "Format" { set a_codec $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_audio_format) $second] }
- "Format/Info" { set a_codec_prof $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_audio_codecprofile) $second] }
- "Bit rate" { set a_bitrate $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_audio_bitrate) $second] }
- "Bit rate mode" { set a_bitrate_mode $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_audio_brmode) $second] }
- "Channel(s)" { set a_chans $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_audio_channels) $second] }
- "Channel positions" { set a_chanpos $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_audio_chanpos) $second] }
- "Sampling rate" { set a_srate $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_audio_samprate) $second] }
- "Writing library" { set a_WriteLib $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_audio_writelib) $second] }
- "Resolution" { set a_res $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_audio_res) $second]}
- }
- }
- if {$type == "v"} {
- switch -- $first {
- "Format_info" { set v_codec_info $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_format) $second] }
- "Format/Info" { set v_codec_family $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_formatinfo) $second] }
- "Codec settings/Packe" { set v_codec_pack $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_pack) $second] }
- "Codec settings/BVOP" { set v_codec_bvop $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_bvop) $second] }
- "Codec settings/QPel" { set v_codec_qpel $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_qpel) $second] }
- "Codec settings/GMC" { set v_codec_gmc $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_gmc) $second] }
- "Codec settings/Matri" { set v_codec_matrix $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_matrix) $second] }
- "Codec" { set v_codec $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_codec) $second] }
- "Width" { set v_width [lindex $second 0] ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_width) $second] }
- "Height" { set v_height [lindex $second 0] ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_height) $second] }
- "Display aspect ratio" { set v_ar $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_aspect) $second] }
- "Bit rate" { set v_br $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_bitrate) $second] }
- "Frame rate" { set v_fr $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_framerate) $second] }
- "Format profile" { set v_fp $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_formatprof) $second] }
- "Format settings, ReFrames" { set v_rf $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_resframes) $second] }
- "Codec ID" { set v_codec $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_codecid) $second] }
- "Standard" { set v_standard $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_standard) $second] }
- "Interlacement" { set v_interlace $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_interlace) $second] }
- "Resolution" { set v_resolution $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_resolution) $second] }
- "Chroma" { set v_chroma [regsub -all " " $second ":"] ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_chroma) $second] }
- "Writing library" { set w_writelib $second ; append samplemessage [regsub -all {%value} $ioNJ(sample_video_writelib) $second] }
- }
- }
- }
- append samplemessage $ioNJ(sample_footer)
- set samplemessage [string map "%ioNiNJA_VER $ioNJ(VER)" $samplemessage]
- set exchange [regexp -all -inline {%fm([\-]?)([0-9]+)\{([^\{\}]+)\}} $samplemessage]
- foreach {crap 1 2 replacing} $exchange {
- if {![string is integer -strict $2]} { continue }
- if {[string length $replacing] > $2} {
- set replace [string range $replacing 0 [expr $2 - 1]]
- } else {
- set replace $replacing
- }
- set samplemessage [string map [list "%fm$1$2\{$replacing\}" [format %${1}${2}s "$replace"]] $samplemessage]
- }
- if {![info exists g_format]} {
- if {[info exists v_codec]} {
- set g_format $v_codec
- } else {
- set g_format "default"
- }
- }
- if {$a_chans == "2 channels" && $a_chanpos == "N/A" } { set a_chanpos "L R" }
- if {![file exists [resolve pwd $pwd]/.ioFTPD.message] && [regexp -nocase {/sample/} $pwd]} {
- writefile $path/.ioFTPD.message "$samplemessage"
- catch {file attributes "$path/.ioFTPD.message" -hidden 1}
- }
- if {[regexp -nocase "/sample" $pwd]} {
- if {[string match -nocase "*AVI*" $g_format]} {
- put_log "SAMPLE_AVI: [list $pwd [resolve uid $uid] [resolve gid $gid] $v_codec $v_fr $v_br $v_height $v_width $v_ar $v_resolution $w_writelib $v_chroma $v_interlace $v_codec_matrix $v_codec_gmc $v_codec_pack $v_codec_qpel $v_codec_bvop $a_codec $a_bitrate $a_bitrate_mode $a_chans $a_srate $a_res $a_codec_prof $a_WriteLib $a_chanpos]"
- } elseif {[string match -nocase "*Windows Media*" $g_format]} {
- put_log "SAMPLE_WMV: [list $pwd [resolve uid $uid] [resolve gid $gid] $v_codec $v_br $v_height $v_width $v_ar $v_resolution $a_codec $a_bitrate $a_chans $a_srate]"
- } elseif {[string match -nocase "*MPEG-1*" $g_format]} {
- put_log "SAMPLE_MPEG: [list $pwd [resolve uid $uid] [resolve gid $gid] $v_codec $v_fr $v_br $v_height $v_width $v_ar $v_interlace $v_codec_matrix $a_codec $a_bitrate $a_bitrate_mode $a_chans $a_srate $a_res $a_WriteLib $a_chanpos]"
- } elseif {[string match -nocase "*MPEG-2*" $g_format]} {
- put_log "SAMPLE_MPEG2: [list $pwd [resolve uid $uid] [resolve gid $gid] $v_codec $v_fr $v_br $v_height $v_width $v_ar $v_interlace $v_standard $a_codec $a_bitrate $a_bitrate_mode $a_chans $a_srate $a_chanpos]"
- } elseif {[string match -nocase "*Matroska*" $g_format]} {
- put_log "SAMPLE_MATROSKA: [list $pwd [resolve uid $uid] [resolve gid $gid] $g_bitrate $v_codec $v_fr $v_height $v_width $v_ar $a_codec $a_chans $a_srate $a_chanpos]"
- } elseif {[string match -nocase "*RealVideo*" $g_format]} {
- put_log "SAMPLE_REAL: [list $pwd [resolve uid $uid] [resolve gid $gid] $v_codec $v_fr $v_br $v_height $v_width $v_ar $v_resolution $v_ar $a_codec $a_bitrate $a_chans $a_res]"
- } elseif {[string match -nocase "*QuickTime*" $g_format]} {
- put_log "SAMPLE_QT: [list $pwd [resolve uid $uid] [resolve gid $gid] $v_codec $v_fr $v_br $v_height $v_width $v_ar $a_codec $a_bitrate $a_chans $a_srate $a_res]"
- } else {
- put_log "SAMPLE_GENERAL: [list $pwd [resolve uid $uid] [resolve gid $gid] $v_codec $v_fr $v_br $v_height $v_width $v_ar $a_codec $a_bitrate $a_bitrate_mode $a_chans $a_srate $a_res]"
- }
- vfs chattr [file dirname $path] 20 "[list $v_codec $v_fr $v_br $v_height $v_width $v_ar $a_codec $a_bitrate $a_bitrate_mode $a_chans $a_srate $a_res]"
- output $samplemessage
- } else {
- vfs chattr $path 20 "[list $v_codec $v_fr $v_br $v_height $v_width $v_ar $a_codec $a_bitrate $a_bitrate_mode $a_chans $a_srate $a_res]"
- }
- symlink_proc sample 0
- return
- }
- proc ::ioNiNJA::get_files {dir pattern} {return [glob -nocomplain -type f -directory $dir $pattern]}
- proc ::ioNiNJA::get_dirs {dir pattern} {return [glob -nocomplain -type d -directory $dir $pattern]}
- proc ::ioNiNJA::get_file_name {} {global path
- set fname ""
- set rarfname [lindex [get_files $path {*{.rar,.001}}] 0]
- if {$rarfname != ""} {
- if {[catch {set fname [exec -- ../scripts/ioNiNJA/MiSC/unrar.exe lb $rarfname]} error]} {
- set fname ""
- } else {
- set fname [file rootname $fname]
- }
- }
- if {$fname == ""} {
- set fname [file rootname [lindex [get_files $path {*{.mkv,.avi,.asf,.m2v,.mpg,.mpeg,.divx,.wmv,.mp4,.img,.iso,.bin,.rar,.001}}] 0]]
- if {$fname == ""} {
- set fname [file rootname [lindex [get_files $path {*{.nfo,.sfv}}] 0]]
- if {$fname == ""} {
- set fname [lindex [file split $path] end]
- }
- }
- }
- return $fname
- }
- #######################
- # get time vars
- #######################
- proc ::ioNiNJA::get_time {time} {
- set return [clock format $time -format "%%a %a %%A %A %%b %b %%B %B %%C %C %%d %d %%e %e %%g %g %%G %G %%h %h %%I %I %%j %j %%k %k %%l %l %%m %m %%M %M %%p %p %%u %u %%U %U %%V %V %%w %w %%W %W %%y %y %%Y %Y"]
- }
- #######################
- # get time vars
- #######################
- proc ::ioNiNJA::get_sorted_time {dirs} {
- set return_dirs ""
- foreach dir $dirs {
- lappend return_dirs [list $dir [file mtime $dir]]
- }
- return [lsort -increasing -integer -index 1 "$return_dirs"]
- }
- #######################
- ## Output to ftpd
- #######################
- proc ::ioNiNJA::output {message} {global ioNJ
- regsub -all %ioNiNJA_VER $message $ioNJ(VER) message
- foreach line [split [string trim $message] \n] {
- iputs -nobuffer "$line"
- }
- }
- proc ::ioNiNJA::outputerror {message} {global ioNJ
- regsub -all %ioNiNJA_VER $message $ioNJ(VER) message
- foreach line [split [string trim $message] \n] {
- iputs "$line"
- }
- }
- #######################
- ## Format Size
- #######################
- proc ::ioNiNJA::format_size {amount} {
- foreach dec {0 0 1 2 2 2} unit {KB MB GB TB PB EB} {
- if {abs($amount) >= 1024} {
- set amount [expr $amount / 1024.0]
- } else {break}
- }
- return [format "%.*f%s" $dec $amount $unit]
- }
- #######################
- ## Format Speed
- #######################
- proc ::ioNiNJA::format_speed {value} {
- if {$value > 1024 } {
- set value [format "%.1f" [expr {$value / 1024.0}]]
- set type "MB/s"
- } else {
- set value [format "%.1f" [expr $value * 1.0]]
- set type "KB/s"
- }
- return "$value$type"
- }
- #######################
- ## Read File
- #######################
- proc ::ioNiNJA::readfile {file} {
- if {![file exists $file]} {return ""}
- set openfile [open $file r]
- set fileread [read $openfile]
- close $openfile
- unset -nocomplain openfile
- return $fileread
- }
- #######################
- ## Write File
- #######################
- proc ::ioNiNJA::writefile {file text} {
- set openfile [open $file w]
- puts $openfile $text
- close $openfile
- unset openfile
- return 0
- }
- #######################
- ## Append to file
- #######################
- proc ::ioNiNJA::appendfile {file text} {
- set openfile [open $file a]
- puts $openfile "$text"
- close $openfile
- return 0
- }
- ##
- # Check if something is binary
- ##
- proc ::ioNiNJA::bin_ary {data} {
- return [string trim [expr {[string first \x00 $data]>=0}]]
- }
- proc ::ioNiNJA::save_pic {pic_data} { global ioNJ path pwd
- set images [list "$path/folder.jpg"]
- if {[regexp -nocase $ioNJ(notparent) [file tail $pwd]]} {
- lappend images "[file join [file dirname $path] folder.jpg]"
- }
- if {[string trim $pic_data] == ""} { return }
- if { ![bin_ary $pic_data] } { return }
- foreach image $images {
- catch {file attribute $image -hidden 0}
- set openfile [open $image w]
- fconfigure $openfile -encoding binary -translation binary -buffering full -buffersize 1000000
- puts $openfile $pic_data
- close $openfile
- unset openfile
- if {$ioNJ(hide_folder_pic)} { catch {file attribute "$image" -hidden 1} }
- catch {vfs flush [file dirname $image]}
- }
- unset pic_data
- }
- proc ::ioNiNJA::save_pic_custom {pic_name pic_data} { global ioNJ path pwd
- set images [list "$pic_name"]
- if {[regexp -nocase $ioNJ(notparent) [file tail $pwd]]} {
- lappend images "[file join [file dirname $path] $pickname]"
- }
- if {[string trim $pic_data] == ""} { return }
- if { ![bin_ary $pic_data] } { return }
- foreach image $images {
- catch {file attribute $image -hidden 0}
- set openfile [open $image w]
- fconfigure $openfile -encoding binary -translation binary -buffering full -buffersize 1000000
- puts $openfile $pic_data
- close $openfile
- unset openfile
- catch {vfs flush [file dirname $image]}
- }
- unset pic_data
- }
- proc ::ioNiNJA::save_pic_custom_path {pic_name pic_data} { global ioNJ path pwd
- set images [list "$pic_name"]
- if {[string trim $pic_data] == ""} { return }
- if { ![bin_ary $pic_data] } { return }
- foreach image $images {
- catch {file attribute $image -hidden 0}
- set openfile [open $image w]
- fconfigure $openfile -encoding binary -translation binary -buffering full -buffersize 1000000
- puts $openfile $pic_data
- close $openfile
- unset openfile
- catch {vfs flush [file dirname $image]}
- }
- unset pic_data
- }
- #######################
- ## Write Chattr
- #######################
- proc ::ioNiNJA::writechattr {raceinfo info} { global args pwd path
- set newcell 0
- set maxbytes 3499
- if {[string length $info] <= $maxbytes } { catch {vfs chattr $path $raceinfo "$info"} ; return }
- while {[set temp [string range $info $newcell [expr $newcell + $maxbytes]]] != ""} {
- set newcell [expr $newcell + $maxbytes + 1]
- catch {vfs chattr $path $raceinfo "$temp"}
- incr raceinfo
- }
- return
- }
- #######################
- ## Read Chattr
- #######################
- proc ::ioNiNJA::readchattr {x} { global args pwd path
- set maxbytes 3499
- set new [vfs chattr $path $x]
- if {[string length $new] <= $maxbytes} { return $new }
- incr x
- while {[set info [vfs chattr $path $x]] != ""} {
- append new $info
- incr x
- if {[string length $info] <= $maxbytes} {
- return $new
- }
- }
- return $new
- }
- proc ::ioNiNJA::erasechattr {x} { global args pwd path
- while {[vfs chattr $path $x] != ""} {
- catch {vfs chattr $path $x ""} error
- incr x
- }
- return
- }
- #######################
- ## Read Chattr Parent
- #######################
- proc ::ioNiNJA::readparentchattr {x} { global args pwd path
- set p2 [file dirname $path]
- set maxbytes 1999
- set new [vfs chattr $p2 $x]
- if {[string length $new] <= $maxbytes} { return $new }
- incr x
- while {[set info [vfs chattr $p2 $x]] != ""} {
- append new $info
- incr x
- if {[string length $info] <= $maxbytes} {
- return $new
- }
- }
- return $new
- }
- #######################
- ## putlog
- #######################
- proc ::ioNiNJA::put_log {text} {
- catch {set openfile [open ../logs/ioftpd.log a]}
- catch {puts $openfile "[clock format [clock seconds] -format "%m-%d-%Y %H:%M:%S"] $text"}
- catch {close $openfile}
- return 0
- }
- #######################
- ## Add Genres
- #######################
- proc ::ioNiNJA::add_generes {} {global ioNJ
- foreach genre $ioNJ(genres) {
- catch {group delete $genre}
- regsub -all " " $genre "_" genre
- catch {group create $genre} temp
- }
- iputs "Groups added OK"
- }
- proc ::ioNiNJA::invite {} { global uid gid args
- set nick [lindex $args 1]
- set user [resolve uid $uid]
- set group [resolve gid $gid]
- set flags [get_uinfo $user flags]
- if {$nick == ""} { output "INVITE ERROR: No nick specified" ; return }
- put_log "INVITE: [list $nick $user $group $flags]"
- output " \"$nick\" was invited to join our chan(s)"
- }
- proc ::ioNiNJA::CWD {} { global path pwd uid gid args ioNJ
- if {[readchattr 4] == ""} {
- if {[readchattr 115] == ""} { return }
- writechattr 16 [readchattr 115]
- writechattr 115 ""
- writechattr 50 [readchattr 25]
- writechattr 25 ""
- writechattr 20 [readchattr 45]
- writechattr 45 ""
- writechattr 25 [readchattr 55]
- writechattr 55 ""
- writechattr 30 [readchattr 65]
- writechattr 65 ""
- writechattr 35 [readchattr 75]
- writechattr 75 ""
- writechattr 4 1
- }
- if {!$ioNJ(show_complete_message)} { return }
- if {[set complete [vfs chattr $path 9]] != 1} {
- if {[set imdb [readchattr 30]] != ""} {
- if {[lindex $imdb 0] == "IMDBTV"} {
- set mess $ioNJ(message_tv_imdbinfo)
- set replacevar "%imdb_title {[lindex $imdb 1]} %imdb_url {[lindex $imdb 2]} %imdb_year {[lindex $imdb 3]} %imdb_tv {[lindex $imdb 4]} %imdb_lifetime {[lindex $imdb 5]} %imdb_ratbar {[lindex $imdb 6]} %imdb_rating {[lindex $imdb 7]} %imdb_votes {[lindex $imdb 8]} %imdb_creator {[lindex $imdb 9]} %imdb_cast {[lindex $imdb 10]} %imdb_runtime {[lindex $imdb 11]} %imdb_country {[lindex $imdb 12]} %imdb_language {[lindex $imdb 13]} %imdb_color {[lindex $imdb 14]} %imdb_genre {[lindex $imdb 15]} %imdb_tagline {[lindex $imdb 16]} %imdb_plot {[lindex $imdb 17]} %imdb_usercomment {[lindex $imdb 18]} %imdb_awards {[lindex $imdb 19]} %imdb_limited {[lindex $imdb 20]} %imdb_director {[lindex $imdb 21]} %ep_name {[lindex $imdb 22]} %ep_airdate {[lindex $imdb 23]}"
- } else {
- set mess $ioNJ(message_imdbinfo)
- set replacevar "%imdb_title {[lindex $imdb 0]} %imdb_url {[lindex $imdb 1]} %imdb_year {[lindex $imdb 2]} %imdb_tv {[lindex $imdb 3]} %imdb_lifetime {[lindex $imdb 4]} %imdb_ratbar {[lindex $imdb 5]} %imdb_rating {[lindex $imdb 6]} %imdb_votes {[lindex $imdb 7]} %imdb_director {[lindex $imdb 8]} %imdb_cast {[lindex $imdb 9]} %imdb_mpaa {[lindex $imdb 10]} %imdb_runtime {[lindex $imdb 11]} %imdb_country {[lindex $imdb 12]} %imdb_language {[lindex $imdb 13]} %imdb_color {[lindex $imdb 14]} %imdb_genre {[lindex $imdb 15]} %imdb_tagline {[lindex $imdb 16]} %imdb_plot {[lindex $imdb 17]} %imdb_usercomment {[lindex $imdb 18]} %imdb_awards {[lindex $imdb 19]} %imdb_opengross {[lindex $imdb 20]} %imdb_opencountry {[lindex $imdb 21]} %imdb_openday {[lindex $imdb 22]} %imdb_openyear {[lindex $imdb 23]} %imdb_openscreens {[lindex $imdb 24]} %imdb_screens {[lindex $imdb 25]} %imdb_budget {[lindex $imdb 26]} %imdb_top250 {[lindex $imdb 27]} %imdb_limited {[lindex $imdb 28]}"
- }
- set message "$ioNJ(message_header_plain)"
- append message "$mess"
- append message "$ioNJ(message_footer)"
- ## Change variables in messages
- set message [string map $replacevar $message]
- #
- set exchange [regexp -all -inline {%fm([\-]?)([0-9]+)\{([^\{\}]+)\}} $message]
- foreach {crap 1 2 replacing} $exchange {
- if {![string is integer -strict $2]} { continue }
- if {[string length $replacing] > $2} {
- set replace [string range $replacing 0 [expr $2 - 1]]
- } else {
- set replace $replacing
- }
- set message [string map [list "%fm$1$2\{$replacing\}" [format %${1}${2}s "$replace"]] $message]
- }
- output $message
- }
- return
- }
- set make_time [vfs chattr $path 11]
- set release_type [vfs chattr $path 12]
- set total_files [vfs chattr $path 13]
- set mv_info [vfs chattr $path 14]
- set racestats [readchattr 50]
- set present_files [llength $racestats]
- set sample [readchattr 20]
- set mp3 [readchattr 25]
- set imdb [readchattr 30]
- set total_size 0
- set total_speed 0
- set time [vfs chattr $path 5]
- set user [resolve uid $uid]
- set ugroup [resolve gid $gid]
- set tagline [get_uinfo $user tagline]
- set dir [lindex [file split $pwd] end]
- set groupusers ""
- set replacevar ""
- set racers ""
- set groups ""
- set groupusers ""
- set totalracers ""
- set totalgroups ""
- if {$make_time == ""} { return }
- if {$time == ""} {
- set time [expr $make_time + 100]
- catch {vfs chattr $path 5 $time}
- }
- #sort users and groups.
- foreach {io_fname io_crc io_user io_group io_fsize io_speed} [string trim [join $racestats]] {
- if {[set race_idx [lsearch -glob $racers $io_user]] == "-1"} {
- lappend racers $io_user
- lappend groupusers [list $io_user $io_group]
- lappend total_racers "$io_user $io_group [format %.0f [expr ($io_fsize /1024.0)]] $io_speed 1 [expr 100 / $present_files]"
- } else {
- set temp [lindex $total_racers $race_idx]
- set temp_files [expr [lindex $temp 4] + 1]
- set temp_size [format %.0f [expr [lindex $temp 2] * 1.0 + ($io_fsize /1024.0)]]
- set temp_speed [format %.0f [expr ([lindex $temp 3] + $io_speed) / 2]]
- set temp_percent [expr ($temp_files * 100) / $present_files]
- set total_racers [lreplace $total_racers $race_idx $race_idx "$io_user $io_group $temp_size $temp_speed $temp_files $temp_percent"]
- }
- if {[set g_race_idx [lsearch -glob $groups $io_group]] == "-1"} {
- lappend groups $io_group
- lappend total_groups "$io_group [format %.0f [expr ($io_fsize /1024.0)]] $io_speed 1 [expr 100 / $present_files]"
- } else {
- set temp [lindex $total_groups $g_race_idx]
- set temp_files [expr [lindex $temp 3] + 1]
- set temp_size [format %.0f [expr [lindex $temp 1] * 1.0 + ($io_fsize /1024.0)]]
- set temp_speed [format %.0f [expr ([lindex $temp 2] + $io_speed) / 2]]
- set temp_percent [expr ($temp_files * 100) / $present_files]
- set total_groups [lreplace $total_groups $g_race_idx $g_race_idx "$io_group $temp_size $temp_speed $temp_files $temp_percent"]
- }
- set total_size [format %.0f [expr $total_size * 1.0 + ($io_fsize /1024.0)]]
- set total_speed [expr $total_speed + $io_speed]
- }
- set temp_new_race_stats [lsort -decreasing -integer -index 2 "$total_racers"]
- set rtop 0
- foreach race_stat $temp_new_race_stats {
- incr rtop
- lappend totalracers "$rtop [lindex $race_stat 0] [lindex $race_stat 1] [lindex $race_stat 2] [lindex $race_stat 3] [lindex $race_stat 4] [lindex $race_stat 5]"
- }
- set temp_new_race_stats [lsort -decreasing -integer -index end-3 "$total_groups"]
- set gtop 0
- foreach race_stat $temp_new_race_stats {
- incr gtop
- lappend totalgroups "$gtop [lindex $race_stat 0] [lindex $race_stat 1] [lindex $race_stat 2] [lindex $race_stat 3] [lindex $race_stat 4]"
- }
- # get dirname and change it if it's a subdir. Mostley for announce purpose but also for groupname
- if {[regexp -nocase $ioNJ(notparent) $dir]} {
- set sample [readparentchattr 20]
- set imdb [readparentchattr 30]
- set parent [lindex [file split $pwd] end-1]
- set subdir ${dir}
- set dir "${parent}"
- }
- lassign [get_stats] racer_dayup racer_wkup racer_mnup racer_allup
- set temp_racestats ""
- foreach race_stat $totalracers {
- set dayup [expr [lsearch -glob $racer_dayup "[lindex $race_stat 1] *"] + 1]
- set wkup [expr [lsearch -glob $racer_wkup "[lindex $race_stat 1] *"] + 1]
- set mnup [expr [lsearch -glob $racer_mnup "[lindex $race_stat 1] *"] + 1]
- set allup [expr [lsearch -glob $racer_allup "[lindex $race_stat 1] *"] + 1]
- lappend temp_racestats "$race_stat $dayup $wkup $mnup $allup"
- }
- set totalracers $temp_racestats
- set racestats [lsort -increasing -integer -index end "$racestats"]
- lassign [lindex $racestats end] crap crap u_fastest_name u_fastest_gname crap u_fastest_speed
- lassign [lindex $racestats 0] crap crap u_slowest_name u_slowest_gname crap u_slowest_speed
- append replacevar " %u_slowest_name {$u_slowest_name} %u_slowest_gname {$u_slowest_gname} %u_slowest_speed {[format_speed $u_slowest_speed]} %u_fastest_name {$u_fastest_name} %u_fastest_gname {$u_fastest_gname} %u_fastest_speed {[format_speed $u_fastest_speed]}"
- # MP3INFO
- if {$mp3 != ""} {
- append replacevar " %audio_artist {[lindex $mp3 0]} %audio_album {[lindex $mp3 1]} %audio_title {[lindex $mp3 2]} %audio_bitrate {[lindex $mp3 3]} %audio_mpeglayer {MPEG [lindex $mp3 4] Layer [lindex $mp3 5]} %audio_chanmode {[lindex $mp3 6]} %audio_genre {[lindex $mp3 7]} %audio_year {[lindex $mp3 8]} %audio_samplerate {[lindex $mp3 9]} %audio_lame_version {[lindex $mp3 10]} %audio_lame_preset {[lindex $mp3 11]} %audio_original {[lindex $mp3 12]} %audio_padding {[lindex $mp3 13]} %audio_duration {[lindex $mp3 14]} %audio_track_nr {[lindex $mp3 15]} %audio_vbr_old_or_new {[lindex $mp3 17]} %audio_vbr {[lindex $mp3 16]}"
- }
- # IMDB INFO
- if {$imdb != ""} {
- append replacevar " %imdb_title {[lindex $imdb 0]} %imdb_url {[lindex $imdb 1]} %imdb_year {[lindex $imdb 2]} %imdb_tv {[lindex $imdb 3]} %imdb_liftime {[lindex $imdb 4]} %imdb_ratbar {[lindex $imdb 5]} %imdb_rating {[lindex $imdb 6]} %imdb_votes {[lindex $imdb 7]} %imdb_director {[lindex $imdb 8]} %imdb_cast {[lindex $imdb 9]} %imdb_mpaa {[lindex $imdb 10]} %imdb_runtime {[lindex $imdb 11]} %imdb_country {[lindex $imdb 12]} %imdb_language {[lindex $imdb 13]} %imdb_color {[lindex $imdb 14]} %imdb_genre {[lindex $imdb 15]} %imdb_tagline {[lindex $imdb 16]} %imdb_plot {[lindex $imdb 17]} %imdb_usercomment {[lindex $imdb 18]} %imdb_awards {[lindex $imdb 19]} %imdb_opengross {[lindex $imdb 20]} %imdb_opencountry {[lindex $imdb 21]} %imdb_openday {[lindex $imdb 22]} %imdb_openyear {[lindex $imdb 23]} %imdb_openscreens {[lindex $imdb 24]} %imdb_screens {[lindex $imdb 25]} %imdb_budget {[lindex $imdb 26]} %imdb_top250 {[lindex $imdb 27]} %imdb_limited {[lindex $imdb 28]}"
- }
- # MV_INFO
- if {$mv_info != ""} {
- append replacevar " %mv_genre {[lindex $mv_info 0]} %mv_artist {[lindex $mv_info 1]} %mv_year {[lindex $mv_info 2]} %mv_title {[lindex $mv_info 3]}"
- }
- #SAMPLE INFO
- if {$sample != ""} {
- append replacevar " %video_codec {[lindex $sample 0]} %video_framerate {[lindex $sample 1]} %video_bitrate {[lindex $sample 2]} %video_height {[lindex $sample 3]} %video_width {[lindex $sample 4]} %video_aspect_ratio {[lindex $sample 5]} %video_audio_codec {[lindex $sample 6]} %video_audio_bitrate_mode {[lindex $sample 8]} %video_audio_bitrate {[lindex $sample 7]} %video_audio_chans {[lindex $sample 9]} %video_audio_samplerate {[lindex $sample 10]} %video_audio_resolution {[lindex $sample 11]}"
- set release_type "VIDEO"
- }
- #Set the progressbar
- if {$present_files != 0 && $total_files != 0} {
- set progsigns [format %.0f [expr ($present_files * [string length $ioNJ(charbar_filled)])/$total_files]]
- if {$progsigns == 0} {
- set pbar $ioNJ(charbar_missing)
- } else {
- set pbar [string range $ioNJ(charbar_filled) 0 [expr $progsigns - 1]]
- set pbar "$pbar[string range $ioNJ(charbar_missing) $progsigns end]"
- }
- } else {
- set pbar $ioNJ(charbar_missing)
- }
- set durtimestamp [expr $time - $make_time]
- if {$durtimestamp == 0} { set durtimestamp 1 }
- set duration $durtimestamp
- set missingfiles [expr $total_files - $present_files]
- set percentdone [format %.1f [expr ((100.0 /$total_files) * $present_files)]]
- set percentleft [format %.1f [expr 100 - $percentdone]]
- set avgspeed [format %.0f [expr $total_size / $durtimestamp]]
- if {$avgspeed == 0} { set avgspeed 1 }
- set a_avgspeed [format %.0f [expr $total_size / $durtimestamp]]
- set r_avgspeed [expr $total_speed / $present_files]
- lassign [lindex $totalracers 0] crap u_winner_name u_winner_gname u_winner_mbytes u_winner_avgspeed u_winner_files u_winner_percent
- lassign [lindex $totalgroups 0] crap g_winner_name g_winner_mbytes g_winner_avgspeed g_winner_files g_winner_percent
- set winner_idx [lsearch -glob $groupusers "$u_winner_name *"]
- set lead_groupusers [lreplace $groupusers $winner_idx $winner_idx]
- set user_idx [lsearch -glob $groupusers "$user *"]
- set groupusers [lreplace $groupusers $user_idx $user_idx]
- set a_groupusers $groupusers
- if {$groupusers == ""} { set groupusers "NoOne NoGroup"}
- if {$total_files != $present_files } { set eta [format %.0f [expr (($total_size / $present_files) * $missingfiles) / $avgspeed]] } else { set eta 0 }
- set total_size [format %.0f $total_size]
- set esize [format %.0f [expr ($total_size / $present_files * [format %.1f $total_files])]]
- set tempesize [format %.0f [expr $esize / 1024.0]]
- append replacevar " %ioNiNJA_VER $ioNJ(VER) %sitename {$ioNJ(ssn)} %racers {$racers} %complete_eta \"[duration $eta]\" %percentdone {$percentdone} %rtop {$rtop} %gtop {$gtop} %release {$dir} %total_files {$total_files} %files_uploaded {$present_files} %missing_files {$missingfiles} %estimated_size [format_size $esize] %total_size \"[format_size $total_size]\" %average_speed \"[format_speed $a_avgspeed]\" %race_duration \"[duration $duration]\" %r_avg_speed \"[format_speed $r_avgspeed]\" %progress_bar {$pbar} %time {[clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"]}"
- set message "$ioNJ(message_header)"
- if {$ioNJ(show_user_info)} {
- append message $ioNJ(message_user_header)
- foreach {rtop raceuser racegroup racesize racespeed racefiles racepercent dayup wkup mnup allup} [join $totalracers] {
- append message [string map [list %race_user_dayup $dayup %race_user_wkup $wkup %race_user_mnup $mnup %race_user_allup $allup %race_user_position $rtop %race_user_name $raceuser %race_user_group $racegroup %race_user_files $racefiles %race_user_size [format_size $racesize] %race_user_percent $racepercent %race_user_speed [format_speed $racespeed]] $ioNJ(message_user_body)]
- }
- append message "$ioNJ(message_user_footer)"
- }
- if {$ioNJ(show_group_info)} {
- append message "$ioNJ(message_group_header)"
- foreach {gtop rgroup gracesize gracespeed gracefiles gracepercent} [join $totalgroups] {
- append message [string map [list %race_group_position $gtop %race_group_name $rgroup %race_group_files $gracefiles %race_group_size [format_size $gracesize] %race_group_percent $gracepercent %race_group_speed [format_speed $gracespeed]] $ioNJ(message_group_body)]
- }
- append message "$ioNJ(message_group_footer)"
- }
- if {$mp3 != ""} {
- append message "$ioNJ(message_mp3)"
- }
- if {$sample != ""} {
- append message "$ioNJ(message_sample)"
- }
- if {$mv_info != ""} {
- append message "$ioNJ(message_mv)"
- }
- if {$imdb != ""} {
- append message "$ioNJ(message_imdbinfo)"
- }
- append message "$ioNJ(message_footer)"
- if {[vfs chattr $path 3] == 1 && $ioNJ(custom_group_dirs_complete_message) != ""} {
- if {[file exists $ioNJ(custom_group_dirs_complete_message)]} {
- set message [readfile $ioNJ(custom_group_dirs_complete_message)]
- }
- }
- ## Change variables in messages
- set message [string map $replacevar $message]
- #
- set exchange [regexp -all -inline {%fm([\-]?)([0-9]+)\{([^\{\}]+)\}} $message]
- foreach {crap 1 2 replacing} $exchange {
- if {![string is integer -strict $2]} { continue }
- if {[string length $replacing] > $2} {
- set replace [string range $replacing 0 [expr $2 - 1]]
- } else {
- set replace $replacing
- }
- set message [string map [list "%fm$1$2\{$replacing\}" [format %${1}${2}s "$replace"]] $message]
- #r4nd0m Changes
- set propercwd "250-"
- append propercwd $message
- }
- #r4nd0m Changes - Output variable used to be $message
- output $propercwd
- return
- }
- #######################
- ## Resort
- #######################
- proc ::ioNiNJA::resort {} {global pwd path args ioNJ
- if {[regexp -nocase {mp3|imdb|tv|mv|xxx} [lindex $args 1]]} {
- set type [string toupper [lindex $args 1]]
- set paths [join [get_mountpoints]]
- set new_dirs [list $path $pwd]
- set basedirs [join [join [get_mountpoints]] |]
- set nr 0
- while {[lindex $paths $nr] != ""} {
- set temp [glob -nocomplain -type d -directory [lindex $paths $nr] "*"]
- foreach dir $temp {
- lappend paths $dir
- iputs -nobuffer "Reading: $dir"
- lappend new_dirs $dir [file join [regsub -nocase $basedirs $dir $pwd]]
- }
- incr nr
- }
- unset paths
- foreach {temp_dir temp_pwd} $new_dirs {
- output "RESORT $type: [file tail $temp_dir]"
- set pwd $temp_pwd
- set path $temp_dir
- if {$type == "MP3"} {
- set temp_mp3 [lindex [glob -nocomplain -type f -directory $temp_dir "*.mp3"] 0]
- if {$temp_mp3 != ""} {
- catch {vfs chattr $path 25 ""}
- get_mp3_information "$temp_mp3"
- ::ioNiNJA::MP3::Main
- }
- } elseif {$type == "IMDB"} {
- catch {vfs chattr $path 30 ""}
- iMDB::imdb_readnfo
- } elseif {$type == "TV"} {
- ioTV::MKD
- } elseif {$type == "XXX"} {
- xxxInfo::get_xxx_info
- } elseif {$type == "MV"} {
- MvInfo::get_mv_info
- }
- }
- } else {
- output $ioNJ(resort_help)
- }
- }
- ####
- ## DELETE OLD BARS
- ####
- proc ::ioNiNJA::del_old_bars {} {global ioNJ pwd path
- set oldfiles [glob -nocomplain -directory "$path" "[string map { \[ \\[ \] \\]} $ioNJ(del_progressmeter)]"]
- foreach progeta $oldfiles { catch {file delete -force "$progeta"} }
- set oldfiles [glob -nocomplain -directory "$path" "[string map { \[ \\[ \] \\]} $ioNJ(del_completebar)]"]
- foreach progeta $oldfiles {catch {file delete -force "$progeta"} }
- return
- }
- ###
- # Get Mountpoints from vfs file
- ###
- proc ::ioNiNJA::get_mountpoints {} {global pwd
- set wp ""
- foreach {vp rp} [mountpoints] {
- if {[regexp -nocase "^[string range $pwd 0 end-1]" $vp]} {
- lappend wp $rp
- }
- }
- if {$wp != ""} { return $wp }
- return [resolve pwd $pwd]
- }
- #######################
- ## Rescan
- #######################
- proc ::ioNiNJA::rescan {} {global pwd path args ioNJ speed
- regsub -all {\\} $path {/} path
- if {[regexp -nocase "all" [lindex $args 1]]} {
- set type [string tolower [lindex $args 1]]
- set paths [join [get_mountpoints]]
- set new_dirs ""
- set basedirs [join [join [get_mountpoints]] |]
- set nr 0
- while {[lindex $paths $nr] != ""} {
- set temp [glob -nocomplain -type d -directory [lindex $paths $nr] "*"]
- foreach dir $temp {
- lappend paths $dir
- iputs -nobuffer "Reading: $dir"
- lappend new_dirs $dir [file join [regsub -nocase $basedirs $dir $pwd]]
- }
- incr nr
- }
- unset paths
- } elseif {[regexp -nocase "this" [lindex $args 1]]} {
- set new_dirs ""
- lappend new_dirs $path $pwd
- } else {
- output $ioNJ(rescan_help)
- return
- }
- foreach {path pwd} $new_dirs {
- iputs -nobuffer "RESCAN: [file tail $pwd]"
- writechattr 5 ""
- writechattr 9 ""
- writechattr 10 ""
- writechattr 11 [clock seconds]
- writechattr 13 0
- writechattr 14 ""
- erasechattr 25
- erasechattr 57
- erasechattr 30
- erasechattr 35
- erasechattr 50
- del_old_bars
- foreach file [glob -nocomplain -type f -directory $path "*${ioNJ(missingtag)}"] { catch {file delete -force -- "$file"} }
- set temp [glob -nocomplain -type f -directory $path "*"]
- if {[set nfo_f [lsearch -glob $temp *.nfo]] != "-1"} {
- set temp_nfo [lindex $temp $nfo_f]
- set temp [lreplace $temp $nfo_f $nfo_f]
- set temp [linsert $temp 0 $temp_nfo]
- }
- if {[set sfv_f [lsearch -glob $temp *.sfv]] != "-1"} {
- set temp_sfv [lindex $temp $sfv_f]
- set temp [lreplace $temp $sfv_f $sfv_f]
- set temp [linsert $temp 0 $temp_sfv]
- }
- set passed_f 0
- set failed_f 0
- set passed_size 0
- set failed_size 0
- foreach file $temp {
- set speed 2000
- if {![file exists $file]} { continue }
- set fsize [file size $file]
- lassign [vfs read $file] uid gid crap
- set vf [file join [regsub -nocase $path $file $pwd]]
- set crc [format %08X [crc32 $file]]
- set args [list 1 $file $crc $vf]
- ZipScript::ZipScript 1 $file $crc $vf
- if {![file exists $file]} {
- set passed_size [expr $fsize + $passed_size]
- incr passed_f
- iputs -nobuffer "FAiLED: [file tail $file]"
- } else {
- set failed_size [expr $fsize + $failed_size]
- incr failed_f
- iputs -nobuffer "PASSED: [file tail $file]"
- }
- }
- put_log [list RESCAN: $pwd $passed_f $passed_size $failed_f $failed_size]
- }
- }
- proc ::ioNiNJA::njver {} {global ioNJ
- output "Running ioNiNJA $ioNJ(VERLONG)"
- }
Add Comment
Please, Sign In to add comment