Skip to content
WJunction - Webmaster Forum

Another one of my infamous code snippets

Status
Not open for further replies.
Ok, I wont post the full snippet because not many people need to extract group name and release type and the code isnt that great for that part.

Class: SceneName
Description: Parses the scene format for TV Shows. Persumes that the source follows the correct nameing structure.

PHP:
<?
/*
Class: SceneName
Description: Parses the scene format for TV Shows. Persumes that the source follows the correct nameing structure.

written by splitice (thewarezscene.org)
*/

class SceneName {
    private $text = '';
    private $parsed = array();
    
    private function _parse(){
        $p = explode('.',$this->text);
        $season = array();
        $name = '';
        foreach($p as $v){
            if($v{0}=='S'&&$v{3}=='E'){//Season Number Episode Number
                $season['season'] = (int)($v{1}.$v{2});
                $season['episode'] = (int)($v{4}.$v{5});
            }else if($v{0}=='S'){ //Just season
                $season['season'] = (int)($v{1}.$v{2});
            }else{
                if($season){
                    
                }else{
                    if($name) $name.= ' ';
                    $name.=$v;
                }
            }
        }
        if(!$season){
            trigger_error('SceneName: cant recognise season');
            return false;
        }
        if(!$name){
            trigger_error('SceneName: cant recognise show name');
            return false;
        }
        
        $this->parsed = array('name'=>$name,'show'=>$season);
    }
    
    function name(){
        if(!$this->parsed) $this->_parse();
        
        return $this->parsed['name'];
    }
    
    function show(){
        if(!$this->parsed) $this->_parse();
        
        return $this->parsed['show'];
    }
    
    function SceneName($text){
        $this->text = $text;
    }
    
    function __toString(){
        return $this->text;
    }
}

?>
 

4 comments

infamous implies that it is famous for being bad.
but its not famous either, maybe "useful" would be a better word lol.

Anyway good snippet, just fooling around.
 
Status
Not open for further replies.

About the author

S
Active Member · Joined
2,474
Messages
240
Reactions
63
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom