require File.join(File.dirname(__FILE__), 'sabnzbd') require 'hpricot' require 'open-uri' class TvNZB def self.search_and_download(tv_show, apikey) if tv_show_known?(tv_show) # p url(tv_show) doc = Hpricot(open(url(tv_show))) doc.search("table.standard a[@href^='http://www.tvnzb.com/nzb/']").each do |el| if tv_show.need?(el[:title]) && Sabnzbd.add_url(el[:href], apikey, "tv shows") $stdout.print " #{el[:title]}\n" tv_show.write_yml(el[:title]) end end else $stdout.print "ID not found for '#{tv_show.name}' on tvnzb.com\n" end end private def self.tv_show_known?(tv_show) tv_show_id(tv_show.name) != nil end def self.url(tv_show) "http://www.tvnzb.com/index.php?st=#{tv_show_id(tv_show.name)}" end def self.tv_show_id(name) h = {"Book of Daniel"=>"270", "Dancing With The Stars US"=>"304", "Cane"=>"453", "Threshold"=>"175", "Medium"=>"34", "The Shot"=>"481", "Saturday Night Live"=>"240", "Everybody Loves Raymond"=>"65", "WWE Pay Per Views"=>"360", "CSI New York"=>"181", "On the Lot"=>"327", "The Universe"=>"342", "The Simpsons"=>"61", "Trailer Park Boys"=>"320", "Farscape"=>"290", "Scrubs"=>"39", "Last Comic Standing"=>"377", "According to Jim"=>"73", "Family Guy"=>"106", "Samantha Who"=>"469", "The Princes Of Malibu"=>"138", "Stargate Atlantis"=>"93", "Army Wives"=>"332", "Standoff"=>"364", "Life is Wild"=>"473", "Pepper Dennis"=>"158", "Tru Calling"=>"60", "Days That Shook The World"=>"145", "The Surreal Life"=>"192", "Starved"=>"126", "The Girls Next Door"=>"572", "Gastineau Girls"=>"284", "Extreme Makeover Home Edition"=>"241", "Two and a Half Men"=>"205", "Monkey Life"=>"413", "Doctor Who (2005)"=>"16", "The Mole"=>"515", "Yes Dear"=>"203", "The War At Home"=>"161", "The Border"=>"563", "Gary Unmarried"=>"550", "Numb3rs"=>"8", "Britannia High"=>"556", "Dollhouse"=>"575", "Roseanne"=>"354", "Revelations"=>"52", "Surviving Suburbia"=>"546", "The Middleman"=>"514", "Grease Is The Word (ITV1 UK)"=>"311", "Pushing Daisies"=>"458", "Sophie"=>"494", "MacGyver"=>"359", "Survivor"=>"77", "Men in Trees"=>"478", "The Sopranos"=>"132", "Porn: A Family Business"=>"371", "Being Erica"=>"578", "Just Legal"=>"190", "Dilbert"=>"415", "Hells Kitchen (UK)"=>"599", "Man vs. Wild"=>"387", "Law & Order: SVU"=>"195", "Stacked"=>"53", "College Hill Interns"=>"476", "Sex and the City"=>"245", "Journeyman"=>"420", "Invasion"=>"199", "The King of Queens"=>"84", "Canterburys Law"=>"506", "Neighbours"=>"370", "Reba"=>"85", "Supernatural"=>"166", "CSI"=>"179", "Miami Ink"=>"135", "The No. 1 Ladies Detective Agency"=>"594", "Tripping The Rift"=>"129", "Head Case"=>"592", "Underbelly"=>"510", "La Femme Nikita"=>"277", "K-Ville"=>"439", "Jake In Progress"=>"6", "Clone"=>"561", "Peep Show (Channel 4 UK)"=>"308", "The Comeback"=>"92", "X-Files"=>"389", "Beautiful People"=>"102", "The Chopping Block (US)"=>"581", "Demons (UK)"=>"571", "Hope And Faith"=>"66", "Raising the Bar"=>"540", "Supernanny"=>"491", "Samurai Girl"=>"523", "Commander In Chief"=>"222", "Entourage"=>"91", "Fast Cars And Superstars"=>"362", "The Unit"=>"155", "Life"=>"421", "Beavis and Butthead"=>"261", "Happy Tree Friends"=>"355", "John From Cincinnati"=>"369", "Skins"=>"500", "Dirty Jobs"=>"286", "The Showbiz Show"=>"173", "Ghost Whisperer"=>"217", "Bullrun"=>"317", "90210"=>"526", "Desperate Housewives"=>"29", "Out Of Practice"=>"189", "King Of The Hill"=>"64", "Stankervision"=>"125", "Wanted"=>"100", "The Starter Wife"=>"385", "Big Shots"=>"461", "The Closer"=>"101", "Star Trek Deep Space 9"=>"278", "The Wonder Years"=>"249", "How I Met Your Mother"=>"206", "Wipeout"=>"522", "American Chopper"=>"356", "Side Order of Life"=>"396", "Wife Swap US"=>"208", "Friday Night with Jonathan Ross"=>"479", "The West Wing"=>"169", "The Game"=>"303", "Laguna Beach"=>"154", "Without A Trace"=>"74", "Fallen"=>"410", "Star Trek Enterprise"=>"234", "Are You Smarter Than a 5th Grader?"=>"426", "Dont Forget the Lyrics"=>"399", "This American Life"=>"513", "The Penguins of Madagascar"=>"584", "Flight of the Conchord"=>"384", "Kid Nation"=>"462", "The Xtra Factor"=>"601", "Better Off Ted"=>"583", "The New Adventures of Old Christine"=>"536", "Intervention"=>"344", "Man V Food"=>"574", "Mad TV"=>"41", "Dirt"=>"507", "Moonlight"=>"454", "Destination Truth"=>"504", "Wings"=>"105", "The Daily Show"=>"174", "Lipstick Jungle"=>"496", "Pirate Master"=>"343", "My Own Worst Enemy"=>"541", "Canadas Next Top Model"=>"363", "Eastbound And Down"=>"576", "English Premier League"=>"562", "Corner Gas"=>"130", "WildBoyz"=>"275", "The Lost Room"=>"326", "Crusoe"=>"544", "Alias"=>"3", "M.A.S.H."=>"358", "Charmed"=>"24", "Masters of Horror"=>"248", "Meerkat Manor"=>"433", "Newport Harbor: The Real Orange County"=>"423", "Private Practice"=>"459", "The Business"=>"440", "Worst Week"=>"529", "Americas Got Talent"=>"351", "Little Britain USA"=>"532", "Courting Alex"=>"282", "Til Death"=>"352", "Top Chef"=>"447", "Chopped"=>"577", "The Company"=>"411", "Hells Kitchen"=>"345", "New Tricks"=>"348", "Rob Dyrdeks Fantasy Factory"=>"579", "30 Days"=>"143", "The Riches"=>"322", "Caprica"=>"603", "Doctor Who Confidential"=>"367", "jPod"=>"498", "This Hour Has 22 Minutes"=>"565", "American Hot Rod"=>"427", "Late Show with David Letterman"=>"446", "The Cleaner"=>"527", "Buffy the Vampire Slayer"=>"346", "Seinfeld"=>"107", "Smash Lab"=>"503", "Jail"=>"431", "Avatar: The Last Airbender"=>"467", "Rock Star INXS"=>"116", "Stunt Junkies"=>"287", "Monk"=>"98", "Highlander"=>"250", "Saxondale"=>"419", "The IT Crowd (UK)"=>"441", "Hex"=>"188", "Surface"=>"159", "Reunion"=>"157", "House"=>"164", "Generation Kill"=>"520", "Who Wants To Be A Superhero"=>"395", "Bleak House"=>"247", "7th Heaven"=>"224", "Trust Me"=>"568", "All of Us"=>"242", "The OC"=>"160", "Kings"=>"582", "Fight Girls"=>"374", "Star Trek: The Original Series"=>"383", "South Beach"=>"285", "The 4400"=>"99", "Rita Rocks"=>"558", "The Apprentice"=>"5", "WWE RAW"=>"339", "Prototype This!"=>"559", "Strong Medicine"=>"139", "The Beast"=>"567", "Rocket Man"=>"209", "Cupid"=>"586", "Killer Instinct"=>"200", "Arrested Development"=>"22", "Cashmere Mafia"=>"487", "The Secret Life of the American Teenager"=>"569", "In Justice"=>"268", "Jekyll (UK)"=>"378", "Friday Night Lights"=>"472", "Traveler"=>"328", "The X Factor (UK)"=>"600", "Brat Camp"=>"134", "Battlestar Galactica (2003)"=>"168", "American Dad"=>"63", "Flashpoint"=>"521", "Valentine"=>"554", "Party Down"=>"590", "Baywatch"=>"376", "Flash Gordon"=>"416", "Modern Marvels"=>"151", "Over There"=>"104", "South Park"=>"2", "Hole in the Wall"=>"533", "The Tonight Show with Jay Leno"=>"373", "Brainiac: Science Abuse"=>"316", "Odyssey 5"=>"115", "Las Vegas Law"=>"289", "Everwood"=>"35", "My Fair Brady"=>"252", "Saving Grace"=>"404", "Crossing Jordan"=>"38", "Kolchak: The Night Stalker"=>"257", "Rules of Engagement"=>"450", "Will & Grace"=>"81", "Carnivale"=>"213", "The Ultimate Fighter"=>"335", "Psych"=>"331", "Britains Got Talent"=>"597", "Fear Itself"=>"517", "Still Standing"=>"70", "Big Love"=>"372", "The Singing Bee"=>"391", "Living With Fran"=>"10", "Knight Rider"=>"519", "Mad Men"=>"407", "Run's House"=>"309", "The 70s House"=>"120", "Meet Mister Mom"=>"110", "Six Feet Under"=>"87", "Kitchen Confidential"=>"191", "Dark Angel"=>"267", "30 Rock"=>"299", "The Real Wedding Crashers"=>"340", "Day Break"=>"337", "Wonder Showzen"=>"71", "Boston Legal"=>"183", "Plus One (UK)"=>"573", "American Idol"=>"56", "Masters of Science Fiction"=>"414", "Funland"=>"244", "Real Time with Bill Maher"=>"178", "Fifth Gear"=>"321", "The Sarah Jane Adventures"=>"557", "Punkd"=>"31", "Tommy Lee Goes To College"=>"111", "The Big Bang Theory"=>"449", "Last One Standing"=>"471", "The Man Show"=>"436", "Hidden Palms"=>"329", "The Amazing Race"=>"57", "United States of Tara"=>"570", "ER"=>"83", "My Name Is Earl"=>"194", "Sit Down, Shut Up"=>"602", "Star Wars: The Clone Wars"=>"535", "Regenesis"=>"318", "Deadliest Catch"=>"306", "Law & Order: Trial By Jury"=>"15", "Huff"=>"276", "The Biggest Loser (US)"=>"604", "Terminator The Sarah Connor Chronicles"=>"489", "Topgear Australia"=>"551", "The Inside"=>"89", "Back To You"=>"443", "Dharma & Greg"=>"112", "Sanctuary"=>"310", "Treasure Hunters"=>"424", "Related"=>"221", "Tyler Perrys House of Payne"=>"429", "Mythbusters"=>"281", "Carpoolers"=>"457", "Gossip Girl"=>"452", "The Dresden Files"=>"405", "Love Inc."=>"288", "Painkiller Jane"=>"307", "Greys Anatomy"=>"30", "Dexter"=>"336", "Cuts"=>"226", "Castle"=>"580", "Skating with Celebrities"=>"283", "The Black Donnellys"=>"319", "The IT Crowd"=>"438", "Trading Spouses"=>"253", "Friends"=>"223", "Britains Got More Talent"=>"598", "Secret Diary of a Call Girl"=>"538", "Massive"=>"555", "After the Catch"=>"341", "Criminal Minds"=>"218", "Paranormal State"=>"486", "Lead Balloon"=>"482", "The Return of Jezebel James"=>"509", "The Simple Life"=>"55", "Dallas SWAT"=>"434", "Leverage"=>"560", "Star Trek The Next Generation"=>"236", "Legend Of The Seeker"=>"545", "Ashes to Ashes"=>"493", "October Road"=>"480", "Close To Home"=>"215", "Swingtown"=>"518", "The Academy"=>"349", "Reaper"=>"451", "Terminal City"=>"243", "Airwolf"=>"350", "Still Game"=>"127", "Rome"=>"136", "Reno 911!"=>"108", "24"=>"298", "The Adventures of Tintin"=>"502", "Eleventh Hour (US)"=>"547", "Robot Chicken"=>"380", "Ice Road Truckers"=>"409", "Wire In The Blood"=>"403", "The Mentalist"=>"552", "Cold Case"=>"79", "Dawsons Creek"=>"418", "Joey"=>"76", "CSI Miami"=>"180", "The Venture Brothers"=>"516", "The Apprentice Martha Stewart"=>"227", "Hustle"=>"272", "Barbershop"=>"95", "Stargate SG-1"=>"94", "Head Cases"=>"170", "Get a life"=>"483", "The Loop"=>"368", "The Six Million Dollar Man"=>"256", "George Lopez"=>"212", "Dragonball Z"=>"171", "The Listener"=>"589", "Lincoln Heights"=>"435", "Silent Witness"=>"442", "Dead Zone"=>"146", "Heroes Unmasked"=>"430", "Kyle XY"=>"330", "Sherlock Holmes (1984)"=>"497", "Little Britain"=>"259", "New Amsterdam"=>"501", "Parks and Recreation"=>"595", "E-Ring"=>"201", "The Shield"=>"49", "The Dead Zone"=>"97", "Top Gear"=>"260", "Lie To Me"=>"564", "WWE SmackDown!"=>"338", "Justice League Unlimited"=>"279", "The Hills"=>"417", "South of Nowhere"=>"542", "Rock School"=>"149", "Brotherhood"=>"393", "Viva Laughlin"=>"470", "The Bill Engvall Show"=>"402", "Damages"=>"394", "Late Night with Conan OBrien"=>"465", "Lobster Wars"=>"425", "Law & Order"=>"75", "The Wire"=>"231", "Listen Up"=>"33", "I Dream of Jeannie"=>"537", "Nashville"=>"432", "The Kill Point"=>"398", "Sons of Anarchy"=>"530", "The Colbert Report"=>"204", "Badger Or Bust"=>"334", "Lost"=>"51", "The Bachelor"=>"323", "Californication"=>"406", "Cops"=>"313", "The Apprentice UK"=>"19", "Ax Men"=>"511", "Sleeper Cell"=>"265", "Shameless"=>"280", "Americas Next Top Model"=>"230", "Project Runway"=>"585", "Crash"=>"543", "Eureka"=>"382", "Twins"=>"176", "The A-Team"=>"488", "The Contender"=>"37", "Lexx"=>"246", "Testees"=>"553", "Eli Stone"=>"492", "Fringe"=>"524", "Studio 60 on the Sunset Strip"=>"333", "Aliens in America"=>"468", "Damage Control"=>"124", "The Real World"=>"128", "Extras"=>"121", "Smallville"=>"11", "Breaking Bad"=>"499", "Penn & Teller: Bullshit!"=>"44", "Smoking Room, The"=>"148", "Dirty Sexy Money"=>"460", "In Plain Sight"=>"512", "Egypt"=>"210", "Southland"=>"588", "One Tree Hill"=>"7", "In Treatment"=>"495", "Third Watch"=>"18", "Creature Comforts"=>"347", "Cavemen"=>"456", "American Inventor"=>"353", "The Life and Times of Tim"=>"531", "Celebrity Poker Showdown"=>"117", "Human Weapon"=>"408", "Jack & Bobby"=>"50", "Pretender"=>"271", "Rescue Me"=>"109", "Degrassi The Next Generation"=>"219", "Star Trek Voyager"=>"235", "Heroes"=>"294", "Heartland"=>"381", "Phenomenon"=>"477", "Rick Mercer Report"=>"566", "The Triangle"=>"266", "JAG"=>"67", "Notes from the Underbelly"=>"325", "L.A. Ink"=>"445", "Harpers Island"=>"587", "Womens Murder Club"=>"466", "Freddie"=>"220", "Ghost Hunters"=>"122", "The Boondocks"=>"211", "World Series of Poker"=>"255", "Criss Angel Mindfreak"=>"251", "The Pick-Up Artist"=>"412", "Hooking Up"=>"131", "Shark"=>"448", "Girlfriends"=>"202", "N.C.I.S."=>"182", "Weeds"=>"103", "National Geographic Channel"=>"314", "My Wife and Kids"=>"238", "The L Word"=>"46", "Four Kings"=>"269", "Gilmore Girls"=>"69", "Bionic Woman"=>"366", "Rodney"=>"254", "Mind Of Mencia"=>"147", "Drawn Together"=>"228", "Primeval"=>"593", "Lil Bush - Resident of the United States"=>"375", "The Ex List"=>"548", "ECW on Sci-Fi"=>"392", "Big Brother"=>"114", "Burn Notice"=>"386", "Code Monkeys"=>"401", "That 70s Show"=>"48", "Just for Laughs"=>"428", "Nip Tuck"=>"196", "The Unusuals"=>"591", "Kitchen Nightmares"=>"444", "Beauty and The Geek"=>"88", "American Gladiators"=>"490", "Crumbs"=>"274", "Space: Above And Beyond"=>"291", "Everybody Hates Chris"=>"216", "Hot Properties"=>"214", "Its Always Sunny in Philadelphia"=>"123", "Greek"=>"388", "Prison Break"=>"144", "Eyes"=>"54", "The Bang"=>"263", "Oz"=>"162", "Viva La Bam"=>"13", "Aqua Teen Hunger Force"=>"508", "Chuck"=>"455", "Spooks"=>"165", "Lewis Blacks: Root of All Evil"=>"505", "Krod Mandoon and the Flaming Sword of Fire"=>"596", "Law & Order: Criminal Intent"=>"62", "Las Vegas"=>"45", "Robin Hood"=>"463", "Malcolm in the Middle"=>"25", "Kojak (2005)"=>"36", "Fonejacker"=>"400", "Veronica Mars"=>"12", "Merlin (UK)"=>"534", "Jennas American Sex Star"=>"262", "True Blood"=>"525", "The Sarah Silverman Program"=>"464", "The Cut"=>"152", "The Bernie Mac Show"=>"232", "UFC Unleashed"=>"258", "Privileged"=>"528", "My Kind Of Town"=>"96", "Joan of Arcadia"=>"237", "The Office"=>"43", "TNA iMPACT!"=>"315", "TNA Pay Per Views"=>"361", "Curb Your Enthusiasm"=>"207", "What I Like About You"=>"14", "State Of Mind"=>"397", "Band Of Brothers (HBO)"=>"119", "Jericho"=>"365", "Deadwood"=>"32", "Inferno 999"=>"437", "Meadowlands"=>"379", "Blood Ties"=>"300", "Missing"=>"137", "American Body Shop"=>"390", "Ugly Betty"=>"324", "Pimp My Ride"=>"26", "Brothers And Sisters"=>"301", "Tell Me You Love Me"=>"422", "Life On Mars (USA)"=>"549", "Bones"=>"167", "So You Think You Can Dance"=>"153", "The Tudors"=>"302", "Blind Justice"=>"21", "Nurse Jackie"=>"620"} h[name] end end