Advertisement
Guest User

xbmc freecable

a guest
May 28th, 2013
1,988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 62.21 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import xbmcplugin
  4. import xbmc
  5. import xbmcgui
  6. import urllib
  7. import urllib2
  8. import sys
  9. import os
  10. import time
  11. #import md5
  12. import tempfile
  13. import addoncompat
  14. from BeautifulSoup import BeautifulStoneSoup
  15.  
  16.  
  17. try: from sqlite3 import dbapi2 as sqlite
  18. except: from pysqlite2 import dbapi2 as sqlite
  19.  
  20.  
  21. pluginhandle = int (sys.argv[1])
  22. """
  23. PARSE ARGV
  24. """
  25. class _Info:
  26. def __init__(self, s):
  27. args = urllib.unquote_plus(s).split(' , ')
  28. for x in args:
  29. print "X",x
  30. try:
  31. (k,v) = x.split('=', 1)
  32. setattr(self, k, v.strip('"\''))
  33. except:
  34. pass
  35.  
  36. args = _Info(sys.argv[2][1:].replace("&", " , "))
  37.  
  38.  
  39. """
  40. DEFINE
  41. """
  42. site_dict= {'aetv':'A&E',
  43. 'abc': 'ABC',
  44. 'abcfamily': 'ABC Family',
  45. 'adultswim': 'Adult Swim',
  46. 'amc': 'AMC',
  47. 'bio': 'Biography',
  48. 'bravo': 'Bravo',
  49. 'cartoon': 'Cartoon Network',
  50. 'cbs': 'CBS',
  51. 'thecw': 'CW, The',
  52. 'comedy': 'Comedy Central',
  53. 'crackle': 'Crackle',
  54. 'disney':'Disney',
  55. 'disneyxd':'Disney XD',
  56. 'food': 'Food Network',
  57. 'fox': 'FOX',
  58. 'fx': 'FX',
  59. 'gsn': 'Game Show Network',
  60. 'hgtv': 'HGTV',
  61. 'history': 'History Channel',
  62. 'hub':'Hub, The',
  63. 'lifetime': 'Lifetime',
  64. 'marvel': 'Marvel',
  65. 'marvelkids': 'Marvel Kids',
  66. 'mtv': 'MTV',
  67. 'natgeo': 'National Geographic',
  68. 'natgeowild': 'Nat Geo Wild',
  69. 'nbc': 'NBC',
  70. 'nickteen': 'Nick Teen',
  71. 'nicktoons': 'Nick Toons',
  72. 'nick': 'Nickelodeon',
  73. 'oxygen': 'Oxygen',
  74. 'pbs': 'PBS',
  75. 'pbskids': 'PBS Kids',
  76. 'spike': 'Spike',
  77. 'syfy': 'SyFy',
  78. 'tbs': 'TBS',
  79. 'tnt': 'TNT',
  80. 'tvland': 'TV Land',
  81. 'usa': 'USA',
  82. 'vh1': 'VH1',
  83. 'thewbkids': 'WB Kids, The',
  84. 'thewb': 'WB, The',
  85. }
  86.  
  87. site_descriptions= {'aetv': "A&E is Real Life. Drama. Now reaching more than 99 million homes, A&E is television that you can't turn away from; where unscripted shows are dramatic and scripted dramas are authentic. A&E offers a diverse mix of high quality entertainment ranging from the network's original scripted series to signature non-fiction franchises, including the Emmy-winning \'Intervention,\' \'Dog The Bounty Hunter,\' \'Hoarders,\' \'Paranormal State\' and \'Criss Angel Mindfreak,\' and the most successful justice shows on cable, including \'The First 48\' and \'Manhunters.\' The A&E website is located at www.aetv.com.",
  88. 'abc': "ABC Television Network provides broadcast programming to more than 220 affiliated stations across the U.S. The Network encompasses ABC News, which is responsible for news programming on television and other digital platforms; ABC Entertainment Group, a partnership between ABC Studios and ABC Entertainment responsible for the network's primetime and late-night entertainment programming; ABC Daytime, producer of the network's successful cache of daytime programming; as well as ABC Kids, the Network's children's programming platform. ABC's multiplatform business initiative includes the Interactive Emmy Award-winning broadband player on ABC.com.",
  89. 'abcfamily': "ABC Family's programming is a combination of network-defining original series and original movies, quality acquired series and blockbuster theatricals. ABC Family features programming reflecting today's families, entertaining and connecting with adults through relatable stories about today's relationships, told with a mix of diversity, passion, humor and heart. Targeting Millennial viewers ages 14-34, ABC Family is advertiser supported.",
  90. 'adultswim': "Cartoon Network (CartoonNetwork.com), currently seen in more than 97 million U.S. homes and 166 countries around the world, is Turner Broadcasting System, Inc.'s ad-supported cable service now available in HD offering the best in original, acquired and classic entertainment for youth and families. Nightly from 10 p.m. to 6 a.m. (ET, PT), Cartoon Network shares its channel space with Adult Swim, a late-night destination showcasing original and acquired animated and live-action programming for young adults 18-34 ",
  91. 'amc': "AMC reigns as the only cable network in history to ever win the Emmy' Award for Outstanding Drama Series three years in a row, as well as the Golden Globe' Award for Best Television Series - Drama for three consecutive years. Whether commemorating favorite films from every genre and decade or creating acclaimed original programming, the AMC experience is an uncompromising celebration of great stories. AMC's original stories include 'Mad Men,' 'Breaking Bad,' 'The Walking Dead,' 'The Killing' and 'Hell on Wheels.' AMC further demonstrates its commitment to the art of storytelling with AMC's Docu-Stories, a slate of unscripted original series, as well as curated movie franchises like AMC's Can't Get Enough and AMC's Crazy About. Available in more than 97 million homes (Source: Nielsen Media Research), AMC is owned and operated by AMC Networks Inc. and its sister networks include IFC, Sundance Channel and WE tv. AMC is available across all platforms, including on-air, online, on demand and mobile. AMC: Story Matters HereSM.",
  92. 'bio': "At Bio, we prove that the truth about people is always more entertaining than fiction. Bio is about real people and their real lives: up close and personal, gritty and provocative, always unfiltered. Bio original series uncover the real drama in people stories: everyday situations with a twist; celebrities going off-script; people-centric crime stories and paranormal events. In addition to being the exclusive home to the Emmy-Award winning Biography' series, Bio's dynamic blend of original and acquired series includes The Final 24, Psychic Investigators and the upcoming William Shatner hosted talk show, Shatner's Raw Nerve. One of the fastest growing cable networks in 2006, the 24-hour network is now available in more than 47 million households. The Bio web site is located at www.bio.tv. ",
  93. 'bravo': "With more breakout stars and critically-acclaimed original series than any other network on cable, Bravo's original programming - from hot cuisine to haute couture - delivers the best in food, fashion, beauty, design and pop culture to the most engaged and upscale audience in cable. Consistently one of the fastest growing top 20 ad-supported cable entertainment networks, Bravo continues to translate buzz into reality with critically-acclaimed breakout creative competition and docu-series, including the Emmy and James Beard Award-winning No. 1 food show on cable \"Top Chef,\" two-time Emmy Award winner \"Kathy Griffin: My Life on the D-List,\" the 14-time Emmy nominated \"Inside the Actors Studio,\" the hit series \"Shear Genius,\" \"Top Chef Masters,\" \"Flipping Out,\" \"The Rachel Zoe Project,\" \"Tabatha's Salon Takeover,\" \"Million Dollar Listing,\" \"The Millionaire Matchmaker,\" and the watercooler sensation that is \"The Real Housewives\" franchise. Bravo reaches its incredibly unique audience through every consumer touch point and across all platforms on-air, online and on the go, providing the network\'s highly-engaged fans with a menu of options to experience the network in a four-dimensional manner. Bravo is a program service of NBC Universal Cable Entertainment, a division of NBC Universal one of the world\'s leading media and entertainment companies in the development, production, and marketing of entertainment, news and information to a global audience. Bravo has been an NBC Universal cable network since December 2002 and was the first television service dedicated to film and the performing arts when it launched in December 1980. For more information visit www.bravotv.com",
  94. 'cartoon': "Cartoon Network (CartoonNetwork.com), currently seen in more than 99 million U.S. homes and 166 countries around the world, is Turner Broadcasting System, Inc.'s ad-supported cable service offering the best in original, acquired and classic animated entertainment for kids and families. Overnight from 10 p.m.-6 a.m. (ET, PT) Monday -Sunday, Cartoon Network shares its channel space with [adult swim], a late-night destination showcasing original and acquired animation for young adults 18-34.",
  95. 'cbs': "CBS was established in 1928, when founder William Paley purchased 16 independent radio stations and christened them the Columbia Broadcast System. Today, with more than 200 television stations and affiliates reaching virtually every home in the United States, CBS's total primetime network lineup is watched by more than 130 million people a week during the 2010/2011 season. The Network has the #1 drama/scripted program, NCIS; #1 sitcom, TWO AND A HALF MEN; #1 newsmagazine, 60 MINUTES; and #1 daytime drama, THE YOUNG AND THE RESTLESS. Its programming arms include CBS Entertainment, CBS News and CBS Sports.",
  96. 'thecw': "The CW Network was formed as a joint venture between Warner Bros. Entertainment and CBS Corporation. The CW is America's fifth broadcast network and the only network targeting women 18-34. The network's primetime schedule includes such popular series as America's Next Top Model, Gossip Girl, Hart of Dixie, 90210, The Secret Circle, Supernatural, Ringer, Nikita, One Tree Hill and The Vampire Diaries.",
  97. 'comedy': "COMEDY CENTRAL, the #1 brand in comedy, is available to over 99 million viewers nationwide and is a top-rated network among men ages 18-24 and 18-34 and adults ages 18-49. With on-air, online and on-the-go mobile technology, COMEDY CENTRAL gives its audience access to the cutting-edge, laugh-out-loud world of comedy wherever they go. Hit series include Tosh.0, Workaholics, Futurama, Key & Peele, Ugly Americans and the Emmy' and Peabody' Award-winning series The Daily Show with Jon Stewart, The Colbert Report and South Park. COMEDY CENTRAL is also involved in producing nationwide stand-up tours, boasts its own record label and operates one of the most successful home entertainment divisions in the industry. COMEDY CENTRAL is owned by, and is a registered trademark of Comedy Partners, a wholly-owned unit of Viacom Inc. (NASDAQ: VIA and VIAB). For more information visit COMEDY CENTRAL's press Web site at www.cc.com/press or the network's consumer site at www.comedycentral.com and follow us on Twitter @ComedyCentralPR for the latest in breaking news updates, behind-the-scenes information and photos.",
  98. 'crackle': "Crackle, Inc. is a multi-platform video entertainment network and studio that distributes full length, uncut, movies, TV shows and original programming in our users favorite genres � like comedy, action, crime, horror, Sci-Fi, and thriller. Crackles channels and shows reach a global audience across the Internet, in the living room, and on devices including a broad range of Sony electronics.",
  99. 'disney':'Disney',
  100. 'disneyxd':'Disney XD',
  101. 'food': "FOOD NETWORK (www.foodnetwork.com) is a unique lifestyle network and Web site that strives to be way more than cooking. The network is committed to exploring new and different ways to approach food - through pop culture, competition, adventure, and travel - while also expanding its repertoire of technique-based information. Food Network is distributed to more than 96 million U.S. households and averages more than seven million Web site users monthly. With headquarters in New York City and offices in Atlanta, Los Angeles, Chicago, Detroit and Knoxville, Food Network can be seen internationally in Canada, Australia, Korea, Thailand, Singapore, the Philippines, Monaco, Andorra, Africa, France, and the French-speaking territories in the Caribbean and Polynesia. Scripps Networks Interactive (NYSE: SNI), which also owns and operates HGTV (www.hgtv.com), DIY Network (www.diynetwork.com), Great American Country (www.gactv.com) and FINE LIVING (www.fineliving.com), is the manager and general partner.",
  102. 'fox': "Fox Broadcasting Company is a unit of News Corporation and the leading broadcast television network among Adults 18-49. FOX finished the 2010-2011 season at No. 1 in the key adult demographic for the seventh consecutive year ' a feat that has never been achieved in broadcast history ' while continuing to dominate all network competition in the more targeted Adults 18-34 and Teen demographics. FOX airs 15 hours of primetime programming a week as well as late-night entertainment programming, major sports and Sunday morning news.",
  103. 'fx': "FX is News Corp.'s flagship general entertainment basic cable network. Launched in 1994, FX is carried in more than 97 million homes and provides a slate of standout original drama series, including Sons of Anarchy, Justified and American Horror Story in addition the comedies It's Always Sunny in Philadelphia, Archer, The League, Louie, Wilfred and Unsupervised. Its diverse schedule includes box-office hits from 20th Century Fox and other major studios, as well as an impressive roster of acquired hit series. FX ranks as the #7 basic cable network in primetime (8-11PM) among P18-49, FX's target demographic. (Most Current thru 10/14/11 among 94 Measured Networks)",
  104. 'gsn': "GSN is a multimedia entertainment company that offers original and classic game programming and competitive entertainment via its 75-million subscriber television network and online game sites. GSN's cross-platform content gives game lovers the opportunity to win cash and prizes, whether through GSN's popular TV game shows or through GSN Digital's free casual games, mobile and social games, and cash competitions. GSN is distributed throughout the U.S., Caribbean and Canada by all major cable operators, satellite providers and telcos. GSN and its subsidiary, WorldWinner.com, Inc., are owned by DIRECTV and Sony Pictures Entertainment. For further information, visit GSN at www.gsn.com.",
  105. 'hgtv': "HGTV makes everyone feel at home everywhere - no matter where they live, work or play. Providing a wide range of lifestyle entertainment that showcases practical advice and fresh ideas from experts in design, architecture, building/remodeling, real estate and more, HGTV inspires viewers to reinvent and transform their own communities, workplaces and shared spaces. Through programming that highlights the authentic stories and relevant situations that impact the design, remodeling, landscaping, buying or selling of a home, HGTV gives viewers a peek into the lives, relationships and creative passions of the human family. In 2010, HGTV's primetime series premieres will include: The Outdoor Room; The Antonio Treatment; Marriage Under Construction; Selling New York; Destination Design; Curb Appeal: The Block; and Design School. Returning primetime favorites include: House Hunters International; HGTV Design Star; Divine Design; Dear Genevieve; and Color Splash. The network's weekend morning lineup offers an entertaining twist on \"do it yourself\" with such popular series as Carter Can, Don't Sweat It, Holmes on Homes, Hammer Heads and Over Your Head. Now available in more than 98 million homes, HGTV is part of the Scripps Networks portfolio of lifestyle-oriented cable networks which includes Food Network, DIY, The Cooking Channel (formerly FLN) and GAC-Great American Country. Viewers can find more of what they love about HGTV at HGTV.com, which offers thousands of photos, gardening and decorating ideas, interactive design tools, easy-to-make projects, videos of new or classic programs and more.",
  106. 'history': "HISTORY and HISTORY HD are the leading destinations for revealing, award-winning original non-fiction series and event-driven specials that connect history with viewers in an informative, immersive and entertaining manner across multiple platforms. Programming covers a diverse variety of historical genres ranging from military history to contemporary history, technology to natural history, as well as science, archaeology and pop culture. Among the network's program offerings are hit series such as Ax Men, Battle 360, How The Earth Was Made, Ice Road Truckers, Pawn Stars and The Universe, as well as acclaimed specials including 102 Minutes That Changed America, 1968 with Tom Brokaw, King, Life After People, Nostradamus: 2012 and Star Wars: The Legacy Revealed. HISTORY has earned four Peabody Awards, seven Primetime Emmy' Awards, 12 News & Documentary Emmy' Awards and received the prestigious Governor's Award from the Academy of Television Arts & Sciences for the network's Save Our History' campaign dedicated to historic preservation and history education. Take a Veteran to School Day is the network's latest initiative connecting America's schools and communities with veterans from all wars. The HISTORY web site, located at www.history.com, is the definitive historical online source that delivers entertaining and informative content featuring broadband video, interactive timelines, maps, games, podcasts and more.",
  107. 'hub':"The Hub, a multi-platform joint venture between Discovery Communications (NASDAQ: DISCA, DISCB, DISCK) and Hasbro, Inc. (NYSE: HAS), is a cable and satellite television network featuring original programming as well as content from Discovery's library of award-winning children's educational programming; from Hasbro's rich portfolio of entertainment and educational properties built during the past 90 years; and from leading third-party producers worldwide. The Hub lineup includes animated and live-action series, specials and game shows, and the network extends its content online. The Hub launched October 10, 2010 (10-10-10) in approximately 60 million U.S. households.",
  108. 'lifetime': "A leading force in the entertainment industry, Lifetime Television is the highest-rated women's network, followed only by its sister channel, Lifetime Movie Network. Upon its 1984 launch, Lifetime quickly established itself as a pioneer in the growing cable universe to become the preeminent television destination and escape for women and has long been the number one female-targeted network on all of basic cable among Women 18-49, Women 25-54 and Women 18+. The Network, one of television's most widely distributed outlets, is currently seen in nearly 98 million households nationwide. Lifetime is synonymous with providing critically acclaimed, award-winning and popular original programming for women that spans movies and miniseries, dramas, comedies and reality series. In continuing this tradition, the Network has aggressively expanded its original programming slate, and, for the 2009-10 season, has amassed the most powerful line-up in Company history.",
  109. 'marvel': 'Marvel started in 1939 as Timely Publications, and by the early 1950s had generally become known as Atlas Comics. Marvel\'s modern incarnation dates from 1961, the year that the company launched Fantastic Four and other superhero titles created by Stan Lee, Jack Kirby, Steve Ditko, and others. Marvel counts among its characters such well-known properties as Spider-Man, the X-Men, the Fantastic Four, Iron Man, the Hulk, Thor, Captain America and Daredevil; antagonists such as the Green Goblin, Magneto, Doctor Doom, Galactus, and the Red Skull. Most of Marvel\'s fictional characters operate in a single reality known as the Marvel Universe, with locations that mirror real-life cities such as New York, Los Angeles and Chicago.',
  110. 'marvelkids': 'Marvel started in 1939 as Timely Publications, and by the early 1950s had generally become known as Atlas Comics. Marvel\'s modern incarnation dates from 1961, the year that the company launched Fantastic Four and other superhero titles created by Stan Lee, Jack Kirby, Steve Ditko, and others. Marvel counts among its characters such well-known properties as Spider-Man, the X-Men, the Fantastic Four, Iron Man, the Hulk, Thor, Captain America and Daredevil; antagonists such as the Green Goblin, Magneto, Doctor Doom, Galactus, and the Red Skull. Most of Marvel\'s fictional characters operate in a single reality known as the Marvel Universe, with locations that mirror real-life cities such as New York, Los Angeles and Chicago.',
  111. 'mtv': "MTV is Music Television. It is the music authority where young adults turn to find out what's happening and what's next in music and popular culture. MTV reaches 412 million households worldwide, and is the #1 Media Brand in the world. Only MTV can offer the consistently fresh, honest, groundbreaking, fun and inclusive youth-oriented programming found nowhere else in the world. MTV is a network that transcends all the clutter, reaching out beyond barriers to everyone who's got eyes, ears and a television set.",
  112. 'natgeo': "Critically acclaimed non-fiction. Network providing info-rich entertainment that changes the way you see the world. A trusted source for more than 100 years, National Geographic provides NGC with unique access to the most respected scientists, journalists and filmmakers, resulting in innovative and contemporary programming of unparalleled quality. NGC HD continues to provide spectacular imagery that National Geographic is known for in stunning high-definition. A leader on the digital landscape, NGC HD is one of the top five HD networks and is the #1 channel viewers would most like to see in high definition for the fourth year in a row. Additionally, the channel received some of the highest ratings in key categories, such as 'high quality,' 'information' and 'favorite' in the prestigious benchmark study among all 55 measured cable and broadcast networks. In addition, NGC VOD is a category leader. Building on its success as one of the fastest-growing cable networks year-to-year in ratings and distribution since launching in January 2001, NGC now reaches more than 70 million homes, with carriage on all major cable and satellite television providers. Highlighted programming in 2010 includes: New episodes of Expedition Great White, the popular series, Taboo and Border Wars. In addition, new seasons of series' WORLD'S TOUGHEST FIXES and LOCKED UP ABROAD. 2010 specials include DRUGS, INC., LOST GOLD OF THE DARK AGES and GREAT MIGRATIONS For more information, please visit www.natgeotv.com.",
  113. 'natgeowild': "Experience the best, most intimate encounters with wildlife ever seen on television. Backed by its unparallel reputation and blue chip programming, Nat Geo Wild brings viewers documentaries entirely focused on the animal kingdom and the world it inhabits. From the most remote environments, to the forbidding depths of our oceans, to the protected parks in our backyards, Nat Geo Wild uses spectacular cinematography and intimate storytelling to take viewers on unforgettable journeys into the wild world. Nat Geo Wild launched in August 2006 and is now available in Hong Kong, Singapore, the U.K., Australia, Latin America, France, Italy, Portugal, Turkey and other territories in Europe. Nat Geo Wild HD launched in the U.K. in March 2009 and is also available in Poland. Additional launches are expected globally.",
  114. 'nbc': "NBC Entertainment develops and schedules programming for the network's primetime, late-night, and daytime schedules. NBC's quality programs and balanced lineup have earned the network critical acclaim, numerous awards, and ratings success. The network has earned more Emmy Awards than any network in television history. NBC's roster of popular scripted series includes critically acclaimed comedies like Emmy winners The Office, starring Steve Carell, and 30 Rock, starring Alec Baldwin and Tina Fey. Veteran, award-winning dramas on NBC include Law & Order: SVU, Chuck, and Friday Night Lights. Unscripted series for NBC include the hits The Biggest Loser, Celebrity Apprentice, and America's Got Talent. NBC's late-night story is highlighted by The Tonight Show with Jay Leno, Late Night with Jimmy Fallon, Last Call with Carson Daly, and Saturday Night Live. NBC Daytime's Days of Our Lives consistently finishes among daytime's top programs in the valuable women 18-34 category. Saturday mornings the network broadcasts Qubo on NBC, a three-hour block that features fun, entertaining, and educational programming for kids, including the award-winning, 3-D animated series Veggie Tales.",
  115. 'nickteen': "Launched in April 2002, TeenNick (formerly named The N) features 24-hours of teen programming. Our award-winning and original programming, including Degrassi: The Next Generation, Beyond the Break, The Best Years and The Assistants, presents sharp and thoughtful content that focuses on the real life issues teens face every day. On our Emmy winning website, www.Teennick.com, fans get complete access to behind-the-scenes interviews, pictures and videos, plus a robust community of 2 million members who interact with message boards, user profiles and blogs. TeenNick'۪s broadband channel, The Click, features full-length episodes of the network'۪s hit original series along with outtakes, sneak peeks and webisodes of TeenNick series created exclusively for broadband. The Click provides teens with the ability to create video mash-ups and watch, comment on and share content from their favorite TeenNick shows with all of their friends, wherever they go.",
  116. 'nicktoons': "Nicktoons offers 24 hours of animated programming that includes Wolverine and the X-Men, Iron Man: Armored Adventures, Fantastic Four: World's Greatest Heroes, Speed Racer: The Next Generation, Kappa Mikey and the Nickelodeon Animation Festival, as well as a roster of hits that have defined kids' and animation lovers' TV, including Avatar: The Last Airbender, Danny Phantom, SpongeBob SquarePants, The Fairly OddParents and The Adventures of Jimmy Neutron, Boy Genius. It currently reaches 54 million homes via cable, digital cable and satellite, and can be seen on Cablevision, Charter Communications, Comcast Cable, Cox Communications, DirecTV, DISH Network and Time Warner Cable. Nicktoons is part of the MTV Networks expanded suite of channels available for digital distribution.",
  117. 'nick': "Nickelodeon, now in its 31st year, is the number-one entertainment brand for kids. It has built a diverse, global business by putting kids first in everything it does. The company includes television programming and production in the United States and around the world, plus consumer products, online, recreation, books and feature films. Nickelodeon's U.S. television network is seen in more than 100 million households and has been the number-one-rated basic cable network for 16 consecutive years.",
  118. 'oxygen': "Oxygen Media is a multiplatform lifestyle brand that delivers relevant and engaging content to young women who like to \"live out loud.\" Oxygen is rewriting the rulebook for women's media by changing how the world sees entertainment from a young woman's point of view. Through a vast array of unconventional and original content including \"Bad Girls Club,\" \"Dance Your Ass Off\" and \"Tori & Dean: Home Sweet Hollywood,\" the growing cable network is the premier destination to find unique and groundbreaking unscripted programming. A social media trendsetter, Oxygen is a leading force in engaging the modern young woman, wherever they are, with popular features online including OxygenLive, shopOholic, makeOvermatic, tweetOverse and hormoneOscope. Oxygen is available in 76 million homes and online at www.oxygen.com, or on mobile devices at wap.oxygen.com. Oxygen Media is a service of NBC Universal.",
  119. 'pbs': "PBS and our member stations are America\'s largest classroom, the nation\'s largest stage for the arts and a trusted window to the world. In addition, PBS's educational media helps prepare children for success in school and opens up the world to them in an age-appropriate way.",
  120. 'pbskids': 'PBS Kids is the brand for children\'s programming aired by the Public Broadcasting Service (PBS) in the United States founded in 1993. It is aimed at children ages 2 to 13.',
  121. 'spike': "Spike TV knows what guys like. The brand speaks to the bold, adventuresome side of men with action-packed entertainment, including a mix of comedy, blockbuster movies, sports, innovative originals and live events. Popular shows like The Ultimate Fighter, TNA iMPACT!, Video Game Awards, DEA, MANswers, MXC, and CSI: Crime Scene Investigation, plus the Star Wars and James Bond movie franchises, position Spike TV as the leader in entertainment for men.",
  122. 'syfy': "Syfy is a media destination for imagination-based entertainment. With year round acclaimed original series, events, blockbuster movies, classic science fiction and fantasy programming, a dynamic Web site (www.Syfy.com), and a portfolio of adjacent business (Syfy Ventures), Syfy is a passport to limitless possibilities. Originally launched in 1992 as SCI FI Channel, and currently in 95 million homes, Syfy is a network of NBC Universal, one of the world's leading media and entertainment companies. Syfy. Imagine greater.",
  123. 'tbs': "TBS, a division of Turner Broadcasting System, Inc., is television's top-rated comedy network and is available in 100.1 million households. It serves as home to such original comedy series as My Boys, Neighbors from Hell, Are We There Yet? and Tyler Perry's House of Payne and Meet the Browns; the late-night hit Lopez Tonight, starring George Lopez, and the upcoming late-night series starring Conan O'Brien; hot contemporary comedies like Family Guy and The Office; specials like Funniest Commercials of the Year; special events, including star-studded comedy festivals in Chicago; blockbuster movies; and hosted movie showcases.",
  124. 'tnt': "TNT, one of cable's top-rated networks, is television's destination for drama. Seen in 99.6 million households, the network is home to such original series as The Closer, starring Kyra Sedgwick; Leverage, starring Timothy Hutton; and Dark Blue, starring Dylan McDermott; the upcoming Rizzoli & Isles, starring Angie Harmon and Sasha Alexander; Memphis Beat, with Jason Lee; Men of a Certain Age, with Ray Romano, Andre Braugher and Scott Bakula; and Southland, from Emmy'-winning producer John Wells (ER). TNT also presents such powerful dramas as Bones, Supernatural, Las Vegas, Law & Order, CSI: NY, Cold Case and Numb3rs; broadcast premiere movies; compelling primetime specials, such as the Screen Actors Guild Awards'; and championship sports coverage, including NASCAR and the NBA. The NCAA men's basketball tournament will appear on TNT beginning in 2011. TNT is available in high-definition.",
  125. 'tvland': "TV Land is dedicated to presenting the best in entertainment on all platforms for consumers in their 40s. Armed with a slate of original programming, acquired classic shows, hit movies and fullservice website, TV Land is now seen in over 98 million U.S. homes. TV Land PRIME is TV Land's prime time programming destination designed for people in their mid-forties and the exclusive home to the premieres of the network's original programming, contemporary television series acquisitions and movies.",
  126. 'usa': "USA Network is cable television's leading provider of original series and feature movies, sports events, off-net television shows, and blockbuster theatrical films. USA Network is seen in over 88 million U.S. homes. The USA Network web site is located at www.usanetwork.com. USA Network is a program service of NBC Universal Cable a division of NBC Universal, one of the world's leading media and entertainment companies in the development, production and marketing of entertainment, news and information to a global audience.",
  127. 'vh1': "VH1 connects viewers to the music, artists and pop culture that matter to them most with series, specials, live events, exclusive online content and public affairs initiatives. VH1 is available in 90 million households in the U.S. VH1 also has an array of digital services including VH1 Classic, VH1 Soul and VSPOT, VH1's broadband channel. Connect with VH1 at www.VH1.com.",
  128. 'thewbkids': 'The KidsWB Collection of Scooby-Doo, Looney Toons, Batman: The Brave and the Bold, Hanna-Barbera, DC and Warner stars under one roof.',
  129. 'thewb': "TheWB.com is the 1 fan site for shows targeted to adults 18-34. Whether it's the familiar ones you love or the new and the original series made only for the web, TheWB.com paves the way as a premium video entertainment destination. It's TV online. On TheWB.com, you can watch full-length episodes of One Tree Hill, The O.C., Buffy the Vampire Slayer, Gilmore Girls, Everwood, Smallville, Friends, Pushing Daisies, Chuck, Jack & Bobby, Angel and Veronica Mars. Plus, it has additional features that include community and message boards, extensive photo galleries, games and downloadable features that allow you to have a deeper relationship with these and other television shows. TheWB.com also offers a line-up of original series made exclusively for the web from some of the top producers in Hollywood, including Sorority Forever, Rich Girl Poor Girl, Childrens' Hospital and the upcoming Rockville CA. TheWB.com is free, ad-supported and available anytime in the U.S. Thank you for your viewership!",
  130. }
  131.  
  132. addoncompat.get_revision()
  133. pluginpath = addoncompat.get_path()
  134. db_path = 'special://home/addons/script.module.free.cable.database/lib/'
  135.  
  136. db_file = os.path.join(xbmc.translatePath(db_path),'shows.db')
  137. cachepath = os.path.join(xbmc.translatePath(pluginpath),'resources','cache')
  138. imagepath = os.path.join(xbmc.translatePath(pluginpath),'resources','images')
  139. fanartpath = os.path.join(xbmc.translatePath(pluginpath),'resources','FAimages')
  140. plugin_icon = os.path.join(xbmc.translatePath(pluginpath),'icon.png')
  141. plugin_fanart = os.path.join(xbmc.translatePath(pluginpath),'fanart.jpg')
  142. fav_icon = os.path.join(xbmc.translatePath(pluginpath),'fav.png')
  143. all_icon = os.path.join(xbmc.translatePath(pluginpath),'allshows.png')
  144.  
  145. """
  146. GET SETTINGS
  147. """
  148.  
  149. settings={}
  150. #settings general
  151. quality = ['200', '400', '600', '800', '1000', '1200', '1400', '1600', '2000', '2500', '3000', '100000']
  152. selectquality = int(addoncompat.get_setting('quality'))
  153. settings['quality'] = quality[selectquality]
  154. settings['enableproxy'] = addoncompat.get_setting('us_proxy_enable')
  155. settings['enablesubtitles'] = addoncompat.get_setting('enablesubtitles')
  156.  
  157. def get_series_id(seriesdata,seriesname):
  158. shows = BeautifulStoneSoup(seriesdata, convertEntities=BeautifulStoneSoup.HTML_ENTITIES).findAll('series')
  159. names = list(BeautifulStoneSoup(seriesdata, convertEntities=BeautifulStoneSoup.HTML_ENTITIES).findAll('seriesname'))
  160. if len(names) > 1:
  161. select = xbmcgui.Dialog()
  162. ret = select.select(seriesname, [name.string for name in names])
  163. if ret <> -1:
  164. seriesid = shows[ret].find('seriesid').string
  165. else:
  166. seriesid = shows[0].find('seriesid').string
  167. return seriesid
  168.  
  169. def tv_db_series_lookup(seriesname,manualSearch=False):
  170. tv_api_key = '03B8C17597ECBD64'
  171. mirror = 'http://thetvdb.com'
  172. banners = 'http://thetvdb.com/banners/'
  173. series_lookup = 'http://www.thetvdb.com/api/GetSeries.php?seriesname='+urllib.quote_plus(seriesname)
  174. seriesdata = getURL(series_lookup)
  175. try: seriesid = get_series_id(seriesdata,seriesname)
  176. except:
  177. if manualSearch:
  178. keyb = xbmc.Keyboard(seriesname, 'Manual Search')
  179. keyb.doModal()
  180. if (keyb.isConfirmed()):
  181. series_lookup = 'http://www.thetvdb.com/api/GetSeries.php?seriesname='+urllib.quote_plus(keyb.getText())
  182. seriesid = getURL(series_lookup)
  183. try: seriesid = get_series_id(seriesid,seriesname)
  184. except:
  185. print 'manual search failed'
  186. return False
  187. else:
  188. return False
  189. series_xml = mirror+('/api/%s/series/%s/en.xml' % (tv_api_key, seriesid))
  190. series_xml = getURL(series_xml)
  191. tree = BeautifulStoneSoup(series_xml, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
  192. #print tree.prettify()
  193. try:
  194. first_aired = tree.find('firstaired').string
  195. date = first_aired
  196. year = int(first_aired.split('-')[0])
  197. except:
  198. print '%s - Air Date Failed' % seriesname
  199. first_aired = None
  200. date = None
  201. year = None
  202. try: genres = tree.find('genre').string
  203. except:
  204. print '%s - Genre Failed' % seriesname
  205. genres = None
  206. try: plot = tree.find('overview').string
  207. except:
  208. print '%s - Plot Failed' % seriesname
  209. plot = None
  210. try: actors = tree.find('actors').string
  211. except:
  212. print '%s - Actors Failed' % seriesname
  213. actors = None
  214. try: rating = float(tree.find('rating').string)
  215. except:
  216. print '%s - Rating Failed' % seriesname
  217. rating = None
  218. try: TVDBbanner = banners + tree.find('banner').string
  219. except:
  220. print '%s - Banner Failed' % seriesname
  221. TVDBbanner = None
  222. try: TVDBfanart = banners + tree.find('fanart').string
  223. except:
  224. print '%s - Fanart Failed' % seriesname
  225. TVDBfanart = None
  226. try: TVDBposter = banners + tree.find('poster').string
  227. except:
  228. print '%s - Poster Failed' % seriesname
  229. TVDBposter = None
  230. try: IMDB_ID = tree.find('imdb_id').string
  231. except:
  232. print '%s - IMDB_ID Failed' % seriesname
  233. IMDB_ID = None
  234. try: runtime = tree.find('runtime').string
  235. except:
  236. print '%s - Runtime Failed' % seriesname
  237. runtime = None
  238. try: Airs_DayOfWeek = tree.find('airs_dayofweek').string
  239. except:
  240. print '%s - Airs_DayOfWeek Failed' % seriesname
  241. Airs_DayOfWeek = None
  242. try: Airs_Time = tree.find('airs_time').string
  243. except:
  244. print '%s - Airs_Time Failed' % seriesname
  245. Airs_Time = None
  246. try: status = tree.find('status').string
  247. except:
  248. print '%s - status Failed' % seriesname
  249. status = None
  250. try: network = tree.find('network').string
  251. except:
  252. print '%s - Network Failed' % seriesname
  253. network = None
  254. return [seriesid,IMDB_ID,TVDBbanner,TVDBposter,TVDBfanart,first_aired,date,year,actors,genres,network,plot,runtime,rating,Airs_DayOfWeek,Airs_Time,status]
  255.  
  256. def load_db():
  257. #if os.path.exists(db_file):
  258. # os.remove(db_file)
  259. if not os.path.exists(db_file):
  260. create_db()
  261. refresh_db()
  262. #else:
  263. # refresh_db()
  264. conn = sqlite.connect(db_file)
  265. c = conn.cursor()
  266. return c.execute('select * from shows order by series_title')
  267.  
  268. def load_status():
  269. conn = sqlite.connect(db_file)
  270. c = conn.cursor()
  271. return c.execute('select distinct status from shows order by status')
  272.  
  273. def list_status():
  274. for status in load_status():
  275. if status[0] <> None:
  276. addDirectory(status[0], 'common', 'list_days')
  277.  
  278. def load_days():
  279. conn = sqlite.connect(db_file)
  280. c = conn.cursor()
  281. return c.execute('select distinct Airs_DayOfWeek from shows order by Airs_DayOfWeek')
  282.  
  283. def list_days():
  284. for day in load_days():
  285. if day[0] <> None:
  286. addDirectory(day[0], 'common', 'list_day',day[0])
  287. xbmcplugin.endOfDirectory( pluginhandle )
  288.  
  289. def load_day(day):
  290. conn = sqlite.connect(db_file)
  291. c = conn.cursor()
  292. return c.execute('select distinct status from shows order by status')
  293.  
  294. def list_day():
  295. for status in load_day():
  296. if status[0] <> None:
  297. addDirectory(status[0], 'common', 'list_days')
  298. xbmcplugin.endOfDirectory( pluginhandle )
  299.  
  300. def load_showlist(favored=False):
  301. shows = load_db()
  302. for series_title,mode,sitemode,url,TVDB_ID,IMDB_ID,TVDBbanner,TVDBposter,TVDBfanart,first_aired,date,year,actors,genres,network,plot,runtime,rating,Airs_DayOfWeek,Airs_Time,status,has_full_episodes,favor,hide in shows:
  303. if addoncompat.get_setting(mode) == 'false':
  304. continue
  305. elif hide:
  306. continue
  307. elif favored and not favor:
  308. continue
  309. thumb=os.path.join(imagepath,mode+'.png')
  310. fanart=''
  311. infoLabels={}
  312. if TVDBfanart:
  313. fanart=TVDBfanart
  314. else:
  315. if args.__dict__.has_key('fanart'): fanart = args.fanart
  316. else: fanart=''
  317. if TVDBbanner:
  318. thumb=TVDBbanner
  319. elif TVDBposter:
  320. thumb=TVDBposter
  321. infoLabels['Title']=series_title.encode('utf-8', 'ignore')
  322. infoLabels['TVShowTitle']=series_title.encode('utf-8', 'ignore')
  323. prefixplot=''
  324. if network<>None:
  325. if site_dict[mode] <> network:
  326. prefixplot+='Network: %s' % network
  327. prefixplot+='\n'
  328. prefixplot+='Station: %s' % site_dict[mode]
  329. prefixplot+='\n'
  330. else:
  331. prefixplot+='Station: %s' % site_dict[mode]
  332. prefixplot+='\n'
  333. else:
  334. prefixplot+='Station: %s' % site_dict[mode]
  335. prefixplot+='\n'
  336. if Airs_DayOfWeek<>None and Airs_Time<>None:
  337. prefixplot+='Airs: %s @ %s' % (Airs_DayOfWeek,Airs_Time)
  338. prefixplot+='\n'
  339. if status<>None:
  340. prefixplot+='Status: %s' % status
  341. prefixplot+='\n'
  342. if prefixplot <> '':
  343. prefixplot+='\n'
  344. if plot<>None:
  345. infoLabels['Plot']=prefixplot.encode('utf-8', 'ignore')+plot.encode('utf-8', 'ignore')
  346. else:
  347. infoLabels['Plot']=prefixplot
  348. if date: infoLabels['date']=date
  349. if first_aired<>None: infoLabels['aired']=first_aired
  350. if year<>None: infoLabels['Year']=year
  351. if actors<>None:
  352. actors = actors.encode('utf-8', 'ignore').strip('|').split('|')
  353. if actors[0] <> '':
  354. infoLabels['cast']=actors
  355. if genres<>None: infoLabels['genre']=genres.encode('utf-8', 'ignore').replace('|',',').strip(',')
  356. if network<>None: infoLabels['studio']=network.encode('utf-8', 'ignore')
  357. if runtime<>None: infoLabels['duration']=runtime
  358. if rating<>None: infoLabels['rating']=rating
  359. addShow(series_title, mode, sitemode, url, thumb, fanart,TVDBposter, infoLabels,favor=favor,hide=hide)
  360.  
  361. def lookup_db(series_title,mode,submode,url,forceRefresh=False):
  362. #print 'Looking Up: %s for %s' % (series_title,mode)
  363. conn = sqlite.connect(db_file)
  364. conn.text_factory = str
  365. c = conn.cursor()
  366. checkdata = c.execute('select * from shows where series_title=? and mode=? and submode =?', (series_title,mode,submode)).fetchone()
  367. if checkdata and not forceRefresh:
  368. if checkdata[3] <> url:
  369. c.execute("update shows set url=? where series_title=? and mode=? and submode =?", (url,series_title,mode,submode))
  370. conn.commit()
  371. return c.execute('select * from shows where series_title=? and mode=? and submode =?', (series_title,mode,submode)).fetchone()
  372. else:
  373. return checkdata
  374. else:
  375. tvdb_data = tv_db_series_lookup(series_title,manualSearch=forceRefresh)
  376. if tvdb_data:
  377. TVDB_ID,IMDB_ID,TVDBbanner,TVDBposter,TVDBfanart,first_aired,date,year,actors,genres,network,plot,runtime,rating,Airs_DayOfWeek,Airs_Time,status = tvdb_data
  378. # series_title,mode,submode,url,TVDB_ID,IMDB_ID,TVDBbanner,TVDBposter,TVDBfanart,first_aired,date,year,actors,genres,network,plot,runtime,rating,Airs_DayOfWeek,Airs_Time,status,has_full_episodes,favor
  379. showdata = [series_title,mode,submode,url,TVDB_ID,IMDB_ID,TVDBbanner,TVDBposter,TVDBfanart,first_aired,date,year,actors,genres,network,plot,runtime,rating,Airs_DayOfWeek,Airs_Time,status,True,False,False]
  380. else:
  381. showdata = [series_title,mode,submode,url,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,True,False,False]
  382. c.execute('insert or replace into shows values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', showdata)
  383. conn.commit()
  384. return c.execute('select * from shows where series_title=? and mode=? and submode =?', (series_title,mode,submode)).fetchone()
  385.  
  386. def lookup_by_TVDBID_plot(tvdb_id):
  387. conn = sqlite.connect(db_file)
  388. conn.text_factory = str
  389. c = conn.cursor()
  390. showdata = c.execute('select * from shows where TVDB_ID =?', (tvdb_id,)).fetchone()
  391. prefixplot=''
  392. if showdata:
  393. series_title,mode,sitemode,url,TVDB_ID,IMDB_ID,TVDBbanner,TVDBposter,TVDBfanart,first_aired,date,year,actors,genres,network,plot,runtime,rating,Airs_DayOfWeek,Airs_Time,status,has_full_episodes,favor,hide = showdata
  394. if network<>None:
  395. prefixplot+='Station: %s' % network
  396. prefixplot+='\n'
  397. if Airs_DayOfWeek<>None and Airs_Time<>None:
  398. prefixplot+='Airs: %s @ %s' % (Airs_DayOfWeek,Airs_Time)
  399. prefixplot+='\n'
  400. if status<>None:
  401. prefixplot+='Status: %s' % status
  402. prefixplot+='\n'
  403. if prefixplot <> '':
  404. prefixplot+='\n'
  405. if plot<>None:
  406. prefixplot=prefixplot.encode('utf-8', 'ignore')+plot.decode("utf-8").encode('utf-8', 'ignore')
  407. return prefixplot
  408.  
  409. def refreshShow():
  410. series_title,mode,submode,url = args.url.split('<join>')
  411. lookup_db(series_title,mode,submode,url,forceRefresh=True)
  412.  
  413. def deleteShow():
  414. series_title,mode,submode,url = args.url.split('<join>')
  415. conn = sqlite.connect(db_file)
  416. conn.text_factory = str
  417. c = conn.cursor()
  418. c.execute('delete from shows where series_title=? and mode=? and submode =?', (series_title,mode,submode))
  419. conn.commit()
  420. c.close()
  421.  
  422. def favorShow():
  423. series_title,mode,submode,url = args.url.split('<join>')
  424. conn = sqlite.connect(db_file)
  425. conn.text_factory = str
  426. c = conn.cursor()
  427. c.execute("update shows set favor=? where series_title=? and mode=? and submode =?", (True,series_title,mode,submode))
  428. conn.commit()
  429. c.close()
  430.  
  431. def unfavorShow():
  432. series_title,mode,submode,url = args.url.split('<join>')
  433. conn = sqlite.connect(db_file)
  434. conn.text_factory = str
  435. c = conn.cursor()
  436. c.execute("update shows set favor=? where series_title=? and mode=? and submode =?", (False,series_title,mode,submode))
  437. conn.commit()
  438. c.close()
  439.  
  440. def hideShow():
  441. series_title,mode,submode,url = args.url.split('<join>')
  442. conn = sqlite.connect(db_file)
  443. conn.text_factory = str
  444. c = conn.cursor()
  445. c.execute("update shows set hide=? where series_title=? and mode=? and submode =?", (True,series_title,mode,submode))
  446. conn.commit()
  447. c.close()
  448.  
  449. def unhideShow():
  450. series_title,mode,submode,url = args.url.split('<join>')
  451. conn = sqlite.connect(db_file)
  452. conn.text_factory = str
  453. c = conn.cursor()
  454. c.execute("update shows set hide=? where series_title=? and mode=? and submode =?", (False,series_title,mode,submode))
  455. conn.commit()
  456. c.close()
  457.  
  458. def create_db():
  459. conn = sqlite.connect(db_file)
  460. conn.text_factory = str
  461. c = conn.cursor()
  462. c.execute('''CREATE TABLE shows(
  463. series_title TEXT,
  464. mode TEXT,
  465. submode TEXT,
  466. url TEXT,
  467. TVDB_ID TEXT,
  468. IMDB_ID TEXT,
  469. TVDBbanner TEXT,
  470. TVDBposter TEXT,
  471. TVDBfanart TEXT,
  472. first_aired TEXT,
  473. date TEXT,
  474. year INTEGER,
  475. actors TEXT,
  476. genres TEXT,
  477. network TEXT,
  478. plot TEXT,
  479. runtime TEXT,
  480. rating float,
  481. Airs_DayOfWeek TEXT,
  482. Airs_Time TEXT,
  483. status TEXT,
  484. has_full_episodes BOOLEAN,
  485. favor BOOLEAN,
  486. hide BOOLEAN,
  487. PRIMARY KEY(series_title,mode,submode)
  488. );''')
  489. conn.commit()
  490. c.close()
  491.  
  492. def refresh_db():
  493. dialog = xbmcgui.DialogProgress()
  494. dialog.create('Caching')
  495. total_stations = len(site_dict)
  496. current = 0
  497. increment = 100.0 / total_stations
  498. for network, name in site_dict.iteritems():
  499. if addoncompat.get_setting(network) == 'true':
  500. percent = int(increment*current)
  501. dialog.update(percent,'Scanning %s' % name,'Grabbing Show list')
  502. exec 'import %s' % network
  503. exec 'showdata = %s.masterlist()' % network
  504. total_shows = len(showdata)
  505. current_show = 0
  506. for show in showdata:
  507. percent = int((increment*current)+(float(current_show)/total_shows)*increment)
  508. dialog.update(percent,'Scanning %s' % name,'Looking up %s' % show[0] )
  509. lookup_db(show[0],show[1],show[2],show[3])
  510. current_show += 1
  511. if (dialog.iscanceled()):
  512. return False
  513. current += 1
  514.  
  515. def formatDate(inputDate='',inputFormat='',outputFormat='%Y-%m-%d',epoch=False):
  516. if epoch:
  517. return time.strftime(outputFormat,time.localtime(epoch))
  518. else:
  519. return time.strftime(outputFormat,time.strptime(inputDate, inputFormat))
  520.  
  521. def setView(type='root'):
  522. confluence_views = [500,501,502,503,504,508]
  523. #types: files, songs, artists, albums, movies, tvshows, episodes, musicvideos
  524. if type == 'root':
  525. xbmcplugin.setContent(pluginhandle, 'movies')
  526. elif type == 'seasons':
  527. xbmcplugin.setContent(pluginhandle, 'movies')
  528. else:
  529. if type == 'tvshows':
  530. xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL)
  531. #xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_STUDIO)
  532. #xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_GENRE)
  533. #xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_DURATION)
  534. #xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_RATING)
  535. #xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_DATE)
  536. xbmcplugin.setContent(pluginhandle, type)
  537. viewenable=addoncompat.get_setting("viewenable")
  538. if viewenable == 'true':
  539. view=int(addoncompat.get_setting(type+'view'))
  540. xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[view])+")")
  541.  
  542. def addVideo(u,displayname,thumb=False,fanart=False,infoLabels=False,HD=False):
  543. if not fanart:
  544. if args.__dict__.has_key('fanart'): fanart = args.fanart
  545. else: fanart = plugin_fanart
  546. if not thumb:
  547. if args.__dict__.has_key('thumb'): thumb = args.thumb
  548. else: thumb = ''
  549. item=xbmcgui.ListItem(displayname, iconImage=thumb, thumbnailImage=thumb)
  550. item.setInfo( type="Video", infoLabels=infoLabels)
  551.  
  552. try:
  553. if HD:
  554. item.addStreamInfo('video', { 'codec': 'h264', 'width':1280 ,'height' : 720 })
  555. else:
  556. item.addStreamInfo('video', { 'codec': 'h264', 'width':720 ,'height' : 400 })
  557. item.addStreamInfo('audio', { 'codec': 'aac', 'channels' : 2 })
  558. except:pass
  559.  
  560. item.setProperty('fanart_image',fanart)
  561. item.setProperty('IsPlayable', 'true')
  562. xbmcplugin.addDirectoryItem(pluginhandle,url=u,listitem=item,isFolder=False)
  563.  
  564. """
  565. ADD DIRECTORY
  566. """
  567.  
  568. def addDirectory(name, mode='', sitemode='', url='', thumb=False, fanart=False, description=False, aired='', genre='',count=0):
  569. if not fanart:
  570. if args.__dict__.has_key('fanart'): fanart = args.fanart
  571. else: fanart = plugin_fanart
  572. if not thumb:
  573. if args.__dict__.has_key('poster'): thumb = args.poster
  574. elif args.__dict__.has_key('thumb'): thumb = args.thumb
  575. else: thumb = ''
  576. if args.__dict__.has_key('name'): showname = args.name
  577. else:showname=''
  578. if not description:
  579. if args.__dict__.has_key('tvdb_id'):
  580. description=lookup_by_TVDBID_plot(args.tvdb_id)
  581. elif site_descriptions.has_key(mode):
  582. description=site_descriptions[mode]
  583. else:
  584. description=''
  585.  
  586.  
  587. infoLabels={ "Title":name,
  588. #"TVShowTitle":showname,
  589. "Genre":genre,
  590. "premiered":aired,
  591. "Plot":description,
  592. "count":count}
  593.  
  594. u = sys.argv[0]
  595. u += '?url="'+urllib.quote_plus(url)+'"'
  596. u += '&mode="'+mode+'"'
  597. u += '&sitemode="'+sitemode+'"'
  598. u += '&thumb="'+urllib.quote_plus(thumb)+'"'
  599. u += '&fanart="'+urllib.quote_plus(fanart)+'"'
  600. u += '&name="'+urllib.quote_plus(name)+'"'
  601. if args.__dict__.has_key('tvdb_id'):
  602. u += '&tvdb_id="'+urllib.quote_plus(args.tvdb_id)+'"'
  603. item=xbmcgui.ListItem(name, iconImage=thumb, thumbnailImage=thumb)
  604. item.setProperty('fanart_image',fanart)
  605. item.setInfo( type="Video", infoLabels=infoLabels)
  606. xbmcplugin.addDirectoryItem(handle=pluginhandle,url=u,listitem=item,isFolder=True)
  607.  
  608. def addShow(series_title, mode='', sitemode='', url='', thumb='', fanart='', TVDBposter=False, TVDB_ID=False, infoLabels=False, favor=False, hide=False):
  609. if not os.path.exists(db_file):
  610. create_db()
  611. if not infoLabels:
  612. infoLabels={}
  613. print "lookup",series_title,mode,sitemode,url
  614. showdata = lookup_db(series_title,mode,sitemode,url)
  615. #series_title,mode,submode,url,TVDB_ID,IMDB_ID,TVDBbanner,TVDBposter,TVDBfanart,first_aired,date,year,actors,genres,network,plot,runtime,rating,Airs_DayOfWeek,Airs_Time,status,has_full_episodes,favor
  616. series_title,mode,sitemode,url,TVDB_ID,IMDB_ID,TVDBbanner,TVDBposter,TVDBfanart,first_aired,date,year,actors,genres,network,plot,runtime,rating,Airs_DayOfWeek,Airs_Time,status,has_full_episodes,favor,hide = showdata
  617. if TVDBfanart:
  618. fanart=TVDBfanart
  619. else:
  620. if args.__dict__.has_key('fanart'): fanart = args.fanart
  621. else: fanart=''
  622. if TVDBbanner:
  623. thumb=TVDBbanner
  624. elif TVDBposter:
  625. thumb=TVDBposter
  626. else:
  627. thumb=os.path.join(imagepath,mode+'.png')
  628. series_title = series_title.decode("utf-8")
  629. infoLabels['Title']=series_title.encode('utf-8', 'ignore')
  630. infoLabels['TVShowTitle']=series_title.encode('utf-8', 'ignore')
  631. prefixplot=''
  632. if network<>None:
  633. if site_dict[mode] <> network:
  634. prefixplot+='Network: %s' % network
  635. prefixplot+='\n'
  636. prefixplot+='Station: %s' % site_dict[mode]
  637. prefixplot+='\n'
  638. else:
  639. prefixplot+='Station: %s' % site_dict[mode]
  640. prefixplot+='\n'
  641. else:
  642. prefixplot+='Station: %s' % site_dict[mode]
  643. prefixplot+='\n'
  644. if Airs_DayOfWeek<>None and Airs_Time<>None:
  645. prefixplot+='Airs: %s @ %s' % (Airs_DayOfWeek,Airs_Time)
  646. prefixplot+='\n'
  647. if status<>None:
  648. prefixplot+='Status: %s' % status
  649. prefixplot+='\n'
  650. if prefixplot <> '':
  651. prefixplot+='\n'
  652. if plot<>None:
  653. infoLabels['Plot']=prefixplot.encode('utf-8', 'ignore')+plot.decode("utf-8").encode('utf-8', 'ignore')
  654. else:
  655. infoLabels['Plot']=prefixplot
  656. if date: infoLabels['date']=date
  657. if first_aired<>None: infoLabels['aired']=first_aired
  658. if year<>None: infoLabels['Year']=year
  659. if actors<>None:
  660. actors = actors.decode("utf-8").encode('utf-8', 'ignore').strip('|').split('|')
  661. if actors[0] <> '':
  662. infoLabels['cast']=actors
  663. if genres<>None: infoLabels['genre']=genres.encode('utf-8', 'ignore').replace('|',',').strip(',')
  664. if network<>None: infoLabels['studio']=network.encode('utf-8', 'ignore')
  665. if runtime<>None: infoLabels['duration']=runtime
  666. if rating<>None: infoLabels['rating']=rating
  667. name = series_title
  668. series_title = series_title.replace(u'\xae','%A9').replace(u'\xe9','%E9').replace(u'\u2122','%99').replace(u'\u2122','%99').replace(u'\u2019','')
  669. u = sys.argv[0]
  670. u += '?url="'+urllib.quote_plus(url)+'"'
  671. u += '&mode="'+mode+'"'
  672. u += '&sitemode="'+sitemode+'"'
  673. u += '&thumb="'+urllib.quote_plus(thumb)+'"'
  674. if TVDB_ID:
  675. u += '&tvdb_id="'+urllib.quote_plus(TVDB_ID)+'"'
  676. if plugin_fanart <> fanart:
  677. u += '&fanart="'+urllib.quote_plus(fanart)+'"'
  678. if TVDBposter:
  679. u += '&poster="'+urllib.quote_plus(TVDBposter)+'"'
  680. u += '&name="'+urllib.quote_plus(series_title)+'"'
  681.  
  682. cm=[]
  683. if favor:
  684. fav_u=sys.argv[0]+"?url=\""+urllib.quote_plus('<join>'.join([series_title,mode,sitemode,url]))+"\"&mode='common'"+"&sitemode='unfavorShow'"
  685. cm.append( ('Remove Favorite %s' % name, "XBMC.RunPlugin(%s)" % fav_u) )
  686. else:
  687. fav_u=sys.argv[0]+"?url=\""+urllib.quote_plus('<join>'.join([series_title,mode,sitemode,url]))+"\"&mode='common'"+"&sitemode='favorShow'"
  688. cm.append( ('Favorite %s' % name, "XBMC.RunPlugin(%s)" % fav_u) )
  689. refresh_u=sys.argv[0]+"?url=\""+urllib.quote_plus('<join>'.join([series_title,mode,sitemode,url]))+"\"&mode='common'"+"&sitemode='refreshShow'"
  690. cm.append( ('Refresh TVDB Data', "XBMC.RunPlugin(%s)" % refresh_u) )
  691. if hide:
  692. hide_u=sys.argv[0]+"?url=\""+urllib.quote_plus('<join>'.join([series_title,mode,sitemode,url]))+"\"&mode='common'"+"&sitemode='unhideShow'"
  693. cm.append( ('UnHide Show', "XBMC.RunPlugin(%s)" % hide_u) )
  694. else:
  695. hide_u=sys.argv[0]+"?url=\""+urllib.quote_plus('<join>'.join([series_title,mode,sitemode,url]))+"\"&mode='common'"+"&sitemode='hideShow'"
  696. cm.append( ('Hide Show', "XBMC.RunPlugin(%s)" % hide_u) )
  697. delete_u=sys.argv[0]+"?url=\""+urllib.quote_plus('<join>'.join([series_title,mode,sitemode,url]))+"\"&mode='common'"+"&sitemode='deleteShow'"
  698. cm.append( ('Delete Show', "XBMC.RunPlugin(%s)" % delete_u) )
  699.  
  700. item=xbmcgui.ListItem(name, iconImage=thumb, thumbnailImage=thumb)
  701. item.addContextMenuItems( cm )
  702. item.setProperty('fanart_image',fanart)
  703. item.setInfo( type="Video", infoLabels=infoLabels)
  704. xbmcplugin.addDirectoryItem(handle=pluginhandle,url=u,listitem=item,isFolder=True)
  705.  
  706. def getURL( url , values = None ,proxy = False, referer=False):
  707. try:
  708. if proxy == True:
  709. us_proxy = 'http://' + addoncompat.get_setting('us_proxy') + ':' + addoncompat.get_setting('us_proxy_port')
  710. proxy_handler = urllib2.ProxyHandler({'http':us_proxy})
  711. if addoncompat.get_setting('us_proxy_pass') <> '' and addoncompat.get_setting('us_proxy_user') <> '':
  712. print 'Using authenticated proxy: ' + us_proxy
  713. password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
  714. password_mgr.add_password(None, us_proxy, addoncompat.get_setting('us_proxy_user'), addoncompat.get_setting('us_proxy_pass'))
  715. proxy_auth_handler = urllib2.ProxyBasicAuthHandler(password_mgr)
  716. opener = urllib2.build_opener(proxy_handler, proxy_auth_handler)
  717. else:
  718. print 'Using proxy: ' + us_proxy
  719. opener = urllib2.build_opener(proxy_handler)
  720. urllib2.install_opener(opener)
  721.  
  722. print 'FREE CABLE --> common :: getURL :: url = '+url
  723. if values == None:
  724. req = urllib2.Request(url)
  725. else:
  726. data = urllib.urlencode(values)
  727. req = urllib2.Request(url,data)
  728. if referer:
  729. req.add_header('Referer', referer)
  730. req.add_header('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20100101 Firefox/14.0.1')
  731. print "forwardig header"
  732. req.add_header('X-Forwarded-For','12.13.14.15')
  733. #link=openRequest(req,4)
  734. response = urllib2.urlopen(req)
  735. link=response.read()
  736. response.close()
  737. except urllib2.HTTPError, error:
  738. print 'Error reason: ', error
  739. return error.read()
  740. else:
  741. return link
  742.  
  743. def openRequest(req,retry):
  744. try:
  745. response = urllib2.urlopen(req)
  746. link=response.read()
  747. response.close()
  748. except:
  749. if retry>0:
  750. print "RETRY ",retry
  751. time.sleep(5)
  752. link=openRequest(req,retry-1)
  753. return link
  754.  
  755. def getRedirect( url , values = None ,proxy = False, referer=False):
  756. try:
  757. if proxy == True:
  758. us_proxy = 'http://' + addoncompat.get_setting('us_proxy') + ':' + addoncompat.get_setting('us_proxy_port')
  759. proxy_handler = urllib2.ProxyHandler({'http':us_proxy})
  760. if addoncompat.get_setting('us_proxy_pass') <> '' and addoncompat.get_setting('us_proxy_user') <> '':
  761. print 'Using authenticated proxy: ' + us_proxy
  762. password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
  763. password_mgr.add_password(None, us_proxy, addoncompat.get_setting('us_proxy_user'), addoncompat.get_setting('us_proxy_pass'))
  764. proxy_auth_handler = urllib2.ProxyBasicAuthHandler(password_mgr)
  765. opener = urllib2.build_opener(proxy_handler, proxy_auth_handler)
  766. else:
  767. print 'Using proxy: ' + us_proxy
  768. opener = urllib2.build_opener(proxy_handler)
  769. urllib2.install_opener(opener)
  770.  
  771. print 'FREE CABLE --> common :: getRedirect :: url = '+url
  772. if values == None:
  773. req = urllib2.Request(url)
  774. else:
  775. data = urllib.urlencode(values)
  776. req = urllib2.Request(url,data)
  777. if referer:
  778. req.add_header('Referer', referer)
  779. req.add_header('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20100101 Firefox/14.0.1')
  780. req.add_header('X-Forwarded-For','12.13.14.15')
  781. response = urllib2.urlopen(req)
  782. finalurl=response.geturl()
  783. response.close()
  784. except urllib2.HTTPError, error:
  785. print 'Error reason: ', error
  786. return error.read()
  787. else:
  788. return finalurl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement