The branch, frodo has been updated
       via  a9590366543c193e805b0106577d1e273417e56c (commit)
      from  565e6dff8364993783f2cb50b17cea32272d433e (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=a9590366543c193e805b0106577d1e273417e56c

commit a9590366543c193e805b0106577d1e273417e56c
Author: beenje <[email protected]>
Date:   Mon Aug 5 21:00:49 2013 +0200

    [plugin.video.s04tv] updated to version 3.0.0

diff --git a/plugin.video.s04tv/addon.xml b/plugin.video.s04tv/addon.xml
index 3b5c06d..1c5f846 100644
--- a/plugin.video.s04tv/addon.xml
+++ b/plugin.video.s04tv/addon.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<addon id="plugin.video.s04tv" name="S04tv" version="2.0.1" 
provider-name="malte">
+<addon id="plugin.video.s04tv" name="S04tv" version="3.0.0" 
provider-name="malte">
     <requires>
         <import addon="xbmc.python" version="2.1.0"/>
         <import addon="script.module.mechanize" version="0.2.5"/>
@@ -9,15 +9,15 @@
         <provides>video</provides>
     </extension>
     <extension point="xbmc.addon.metadata">
-               <language>de</language>
+        <language>de</language>
         <platform>all</platform>
-               <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 
1991</license>
-               <forum>http://forum.xbmc.org/showthread.php?tid=109692</forum>
-               <website>https://code.google.com/p/xbmc-s04tv/</website>
-               <source>https://xbmc-s04tv.googlecode.com/svn/trunk/</source>
-        <summary lang="de">Videos von S04tv.de ansehen</summary>
-        <summary lang="en">Watch videos from S04tv.de</summary>
-        <description lang="de">Online Video Portal des FC Schalke 04. Alle 
Spiele in re-Live (15 Minuten nach Abfiff), Interviews, exklusive Berichte und 
Specials. Setzt einen S04tv.de Benutzer Account voraus. Mehr Details auf 
https://www.s04tv.de.</description>
-        <description lang="en">FC Schalke 04 online video portal. Watch all 
videos from S04tv.de including all matches in re-Live (15 minutes after the 
match has ended). Requires S04tv.de user account. See https://www.s04tv.de for 
details.</description>
+        <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
+        <forum>http://forum.xbmc.org/showthread.php?tid=109692</forum>
+        <website>https://code.google.com/p/xbmc-s04tv/</website>
+        <source>https://xbmc-s04tv.googlecode.com/svn/trunk/</source>
+        <summary lang="de">Videos von S04.tv ansehen</summary>
+        <summary lang="en">Watch videos from S04.tv</summary>
+        <description lang="de">Online Video Portal des FC Schalke 04. Alle 
Spiele in re-Live (15 Minuten nach Abfiff), News, Interviews, exklusive 
Berichte und Specials. Viele freie Videos, die meisten Videos setzen allerdings 
einen S04.tv Benutzer Account voraus (39,95 EUR/Jahr). Mehr Details auf 
http://www.s04.tv.</description>
+        <description lang="en">FC Schalke 04 online video portal. Watch all 
videos from S04tv.de including all matches in re-Live (15 minutes after the 
match has ended), news, interviews and specials. Lot of free videos, but most 
videos require an S04.tv user account (e.g. 39,95 EUR/year). See 
http://www.s04.tv for details.</description>
     </extension>
 </addon>
diff --git a/plugin.video.s04tv/changelog.txt b/plugin.video.s04tv/changelog.txt
index 2bc8770..18a7423 100644
--- a/plugin.video.s04tv/changelog.txt
+++ b/plugin.video.s04tv/changelog.txt
@@ -1,3 +1,9 @@
+3.0.0 (2013/08)
+- update due to website changes
+- list videos in categories
+- support of free and exclusive videos
+- new options (video quality etc.)
+
 2.0.1 (2013/07):
 - another encoding fix
 
diff --git a/plugin.video.s04tv/default.py b/plugin.video.s04tv/default.py
index 57b8420..7190418 100644
--- a/plugin.video.s04tv/default.py
+++ b/plugin.video.s04tv/default.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 Malte Loepmann ([email protected])
+# Copyright (C) 2013 Malte Loepmann ([email protected])
 #
 # This program is free software; you can redistribute it and/or modify it 
under the terms 
 # of the GNU General Public License as published by the Free Software 
Foundation; 
@@ -11,278 +11,391 @@
 # You should have received a copy of the GNU General Public License along with 
this program; 
 # if not, see <http://www.gnu.org/licenses/>.
 
-import xbmcplugin
-import xbmcgui
-import xbmcaddon
-import os, sys, re
+import xbmc, xbmcplugin, xbmcgui, xbmcaddon
+import os, sys, re, json, string, random
 import urllib, urllib2
 from urlparse import *
+import xml.etree.ElementTree as ET
+
 
 PLUGINNAME = 'S04tv'
 PLUGINID = 'plugin.video.s04tv'
-BASE_URL = 'https://www.s04tv.de/'
+BASE_URL = 'http://www.s04.tv'
 
 # Shared resources
 addonPath = ''
-
-import xbmcaddon
 __addon__ = xbmcaddon.Addon(id='plugin.video.s04tv')
 addonPath = __addon__.getAddonInfo('path')
         
 BASE_RESOURCE_PATH = os.path.join(addonPath, "resources" )
 sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib" ) )
 sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib", "BeautifulSoup" ) )
-sys.path.append( os.path.join( BASE_RESOURCE_PATH, "lib", "mechanize" ) )
 
 from BeautifulSoup import BeautifulSoup
-import mechanize
+from BeautifulSoup import Tag
+
 
 __language__ = __addon__.getLocalizedString
 thisPlugin = int(sys.argv[1])
 
-browser = mechanize.Browser()
+missingelementtext = "Missing element '%s'. Maybe the site structure has 
changed."
 
-
-def buildVideoList(doc):
-    xbmc.log('buildVideoList')
-    
-    #parse complete document
+def buildHomeDir(url, doc):
+    xbmc.log('buildHomeDir')
     soup = BeautifulSoup(''.join(doc))
     
-    container = soup.findAll('div', attrs={'class' : 'layout_full'})
-    if(not container):
-        xbmc.log('Error while building video list. class "layout_full" not 
found.')
+    nav = soup.find('nav')
+    if(not nav):
+        xbmc.log(missingelementtext%'nav')
         return
     
-    #iterate content
-    for content in container[0].contents:
-        #ignore NavigableStrings
-        if(type(content).__name__ == 'NavigableString'):        
-            continue
-                        
-        itemTitle = findTitle(content, 'div', {'class' : 'field Headline'})    
    
-        if(itemTitle == ''):
-            xbmc.log('Error while building video list. class "field Headline" 
not found.')
-            continue
+    for navitem in nav.contents:
+        #first tag is our ul
+        if(type(navitem) == Tag):
+            for ulitem in navitem.contents:
+                if(type(ulitem) == Tag):
+                    if(ulitem.name == 'li'):
+                        a = ulitem.find('a')
+                        if(not a):
+                            xbmc.log(missingelementtext%'a')
+                            continue
+                        url = BASE_URL + a['href']
+                        addDir(a.text, url, 2, '', '')
+            break
         
-        titlePart2 = findTitle(content, 'div', {'class' : 'field untertitel'}) 
       
-        if(titlePart2 == ''):
-            titlePart2 = findTitle(content, 'div', {'class' : 'field 
Beitragsart'})
+
+def buildSubDir(url, doc):
+    xbmc.log('buildSubDir')
+    soup = BeautifulSoup(''.join(doc))
+    
+    nav = soup.find('ul', attrs={'class': 'contentnav'})
+    if(not nav):
+        #no subdir (home page or flat category)
+        buildVideoDir(url, doc)
+        return
+    
+    div =  nav.find('div')
+    if(not div):
+        #no subdir (home page or flat category)
+        buildVideoDir(url, doc)
+        return
+    
+    ul = div.find('ul')
+    for ulitem in ul.contents:
+        if(type(ulitem) == Tag):
+            if(ulitem.name == 'li'):
+                a = ulitem.find('a')
+                if(not a):
+                    xbmc.log(missingelementtext%'a')
+                    continue
+                url = BASE_URL + a['href']
+                addDir(a.text, url, 3, '', '')
         
-        if(titlePart2 != ''):
-            itemTitle = itemTitle +': ' +titlePart2
         
-        linkValue = ''
-        imageUrlValue = ''
-        imageTag = content.find('div', attrs={'class' : 'field Bild'})
-        if(imageTag):
-            link = imageTag.find('a')
-            linkValue = link['href']
-            imageUrl = imageTag.find('img')    
-            imageUrlValue = BASE_URL +imageUrl['src']
-        else:
-            xbmc.log('Error while building video list. class "field Bild" not 
found.')
-            continue
-            
-        url = BASE_URL + linkValue
-        addDir(itemTitle, url, 2, imageUrlValue)
+def buildSubSubDir(url, doc):
+    xbmc.log('buildSubSubDir')
+    soup = BeautifulSoup(''.join(doc))
     
-    #previous page
-    previousTag = soup.find('a', attrs={'class' : 'previous'})
-    if(previousTag):
-        pageLink = previousTag['href']
-        itemTitle = __language__(30002)
-        url = BASE_URL + pageLink
-        addDir(itemTitle, url, 1, '')
+    #get pagenumber
+    indexpage = url.find('page/')
+    indexpage = indexpage + len('page/')
+    indexminus = url.find('-', indexpage)
+    pagenumber = ''
+    if(indexpage >=0 and indexminus > indexpage): 
+        pagenumber = url[indexpage:indexminus]
+    
+    #check if we have corresponding sub menus
+    li = soup.find('li', attrs={'class':'dm_%s'%pagenumber})
+    if(not li):
+        #no sub sub dir
+        buildVideoDir(url, doc)
+        return
+    
+    div =  li.find('div')
+    if(not div):
+        xbmc.log(missingelementtext%'div')
+        return
+    ul = div.find('ul')
+    if(not ul):
+        xbmc.log(missingelementtext%'ul')
+        return
+    for ulitem in ul.contents:
+        if(type(ulitem) == Tag):
+            if(ulitem.name == 'li'):
+                a = ulitem.find('a')
+                if(not a):
+                    xbmc.log(missingelementtext%'a')
+                    continue
+                url = BASE_URL + a['href']
+                addDir(a.text, url, 3, '', '')
+
+
+def buildVideoDir(url, doc):
+    xbmc.log('buildVideoDir')
+    
+    #allow sorting of video titles
+    xbmcplugin.addSortMethod(int(sys.argv[1]), 
xbmcplugin.SORT_METHOD_UNSORTED)    
+    xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE)
+    xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_TITLE)
+    
+    hideexclusive = __addon__.getSetting('hideexclusivevideos').upper() == 
'TRUE'
+    hideflag = __addon__.getSetting('hidefreeexclflag').upper() == 'TRUE'
+    hidedate = __addon__.getSetting('hidedate').upper() == 'TRUE'
     
-    #next page
-    nextTag = soup.find('a', attrs={'class' : 'next'})
-    if(nextTag):
-        pageLink = nextTag['href']
-        itemTitle = __language__(30003)
-        url = BASE_URL + pageLink
-        addDir(itemTitle, url, 1, '')
-
-
-def buildVideoLinks(doc, name):
-    xbmc.log('buildVideoLinks')
-
-    #parse complete document
     soup = BeautifulSoup(''.join(doc))
-    videoTag = soup.find('video')
+    articles = soup.findAll('article')
+    if(not articles):
+        xbmc.log(missingelementtext%'article')
+        return
     
-    if(videoTag):
-        sourceTag = videoTag.find('source')
-        if(sourceTag):
-            videoUrl = sourceTag['src']
-            xbmc.log('start playing video: ' +videoUrl)
-            addLink(name, videoUrl, os.path.join(addonPath, 'icon.png'))
+    for article in articles:
+                
+        div = article.find('div')
+        if(not div):
+            xbmc.log(missingelementtext%'div')
+            continue
+        
+        flag = div['class']
+        
+        #for some reason findNextSibling does not work here
+        p = div.findAllNext('p', limit=1)
+        if(not p):
+            xbmc.log(missingelementtext%'p')
+            continue
+        date = p[0].text
+                
+        img = div.findAllNext('img', limit=1)
+        if(not img):
+            xbmc.log(missingelementtext%'img')
+            continue
+        imageUrl = img[0]['src']
+        
+        #HACK: this is only required on home page
+        h2 = img[0].findAllNext('h2', limit=1)
+        if(h2):
+            a = h2[0].findAllNext('a', limit=1)
+            if(not a):
+                xbmc.log(missingelementtext%'a')
+                continue
+            url = a[0]['href']
+            span = a[0].find('span')
         else:
-            xbmc.log('Error while loading video from page. Maybe you are not 
logged in or site structure has changed.')
-    else:
-        xbmc.log('Error while loading video from page. Maybe you are not 
logged in or site structure has changed.')
+            a = img[0].findAllNext('a', limit=1)
+            if(not a):
+                xbmc.log(missingelementtext%'a')
+                continue
+            url = a[0]['href']
+            span = a[0].find('span')
         
-
-def provideTestvideoDir():
-
-    xbmc.log('provideTestvideo')
+        if(not span):
+            xbmc.log(missingelementtext%'span')
+            continue
+        title = ''
+        for text in span.contents:
+            if(type(text) != Tag):
+                if(title != ''):
+                    title = title +': '
+                title = title +text
+                
+        if(not hidedate):
+            title = title + ' (%s)'%date
+                
+        extraInfo = {}
+        if(flag == 'flag_free'):
+            if(not hideflag):
+                title = '[FREE] ' +title
+            extraInfo['IsFreeContent'] = 'True'
+        elif(flag == 'flag_excl'):
+            if(hideexclusive):
+                #don't add exclusive videos to list
+                continue
+            if(not hideflag):
+                title = '[EXCL] ' +title
+            extraInfo['IsFreeContent'] = 'False'
+                
+        url = BASE_URL + url
+        addDir(title, url, 4, imageUrl, date, extraInfo)
+
+
+def getVideoUrl(url, doc):
+    xbmc.log('getVideoUrl')
     
-    url = 'https://www.s04tv.de/index.php/s04tv-kostenlos.html'
-    browser.open(url)    
-    doc = browser.response().read()
-    soup = BeautifulSoup(''.join(doc))
+    #check if we are allowed to watch this video
+    isFreeContent = xbmc.getInfoLabel( "ListItem.Property(IsFreeContent)" ) == 
'True'
+    if(not isFreeContent):
+        success = login()
+        if(not success):
+            return
     
-    xbmc.log('site loaded')
+    soup = BeautifulSoup(''.join(doc))
     
-    imageTag = soup.find('div', attrs={'class' : 'field Bild'})
-    if(not imageTag):
-        xbmc.log('Error while loading test video. div "field Bild" not found.')
+    #title
+    p = soup.find('p', attrs={'class': 'breadcrumbs'})
+    if(not p):
+        xbmc.log(missingelementtext%'p')
         return
+    a = p.find('a')
+    if(not a):
+        xbmc.log(missingelementtext%'a')
+        return
+    title = a['title']
+    if(title == ''):
+        title = __language__(30005)
     
-    link = imageTag.find('a')
-    if(not link):
-        xbmc.log('Error while loading test video. "a href" not found.')
-    linkValue = link['href']
-    imageUrl = imageTag.find('img')    
-    imageUrlValue = BASE_URL +imageUrl['src']
-    
-    newUrl = BASE_URL +linkValue
+    #grab url
+    div = soup.find('div', attrs={'class': 'videobox'})
+    if(not div):
+        xbmc.log(missingelementtext%'div')
+        return
+    script = div.find('script', attrs={'type': 'text/javascript'})
+    if(not script):
+        xbmc.log(missingelementtext%'script')
+        return
+    scripttext = script.next
+    indexbegin = scripttext.find("videoid: '")
+    indexbegin = indexbegin + len("videoid: '")
+    indexend = scripttext.find("'", indexbegin)
+    xmlurl = ''
+    if(indexbegin >= 0 and indexend > indexbegin):
+        xmlurl = scripttext[indexbegin:indexend]
+    else:
+        xbmc.log('Could not find videoid in script')
+        return
     
-    xbmc.log('new url: ' +newUrl)
-    browser.open(newUrl)
+    #load xml file
+    xmlstring = getUrl(BASE_URL +xmlurl)
+    root = ET.fromstring(xmlstring)
     
-    doc = browser.response().read()
-    soup = BeautifulSoup(''.join(doc))
+    urlElement = root.find('invoke/url')
+    if(urlElement == None):
+        print 'urlElement: ' +str(urlElement)
+        xbmc.log(missingelementtext%'invoke/url')
+        return
     
-    videoTag = soup.find('video')
-    if(not videoTag):
-        xbmc.log('Error while loading test video. "video" tag not found.')
+    xmlstring = getUrl(urlElement.text)
+    root = ET.fromstring(xmlstring)
+    metas = root.findall('head/meta')
+    if(metas == None):
+        xbmc.log(missingelementtext%'head/meta')
         return
-    sourceTag = videoTag.find('source')
-    if(not sourceTag):
-        xbmc.log('Error while loading test video. "video" tag not found.')
+    vid_base_url = ''
+    for meta in metas:
+        if( meta.attrib.get('name') == 'httpBase'):
+            vid_base_url = meta.attrib.get('content')
+            break
+    
+    quality = __addon__.getSetting('videoquality')
+    quality = '_%s.mp4'%quality
+    videos = root.findall('body/switch/video')
+    if(videos == None):
+        xbmc.log(missingelementtext%'body/switch/video')
         return
+    for video in videos:
+        src = video.attrib.get('src')
+        if(src.find(quality) > 0):
+            break
     
-    videoUrl = sourceTag['src']
-    addLink(__language__(30004), videoUrl, imageUrlValue)
+    v = '2.11.3'
+    fp = 'WIN%2011,8,800,97'
+    r = num_gen(5, string.ascii_uppercase)
+    g = num_gen(12, string.ascii_uppercase)
+    videourl = vid_base_url +src +'&v=%s&fp=%s&r=%s&g=%s'%(v,fp,r,g)
+    addLink(title, videourl, '')
 
 
-def addDir(name,url,mode,iconimage):
-    parameters = {'url' : url.encode('utf-8'), 'mode' : str(mode), 'name' : 
__language__(30005)}
+def addDir(name, url, mode, iconimage, date, extraInfo = {}):
+    parameters = {'url' : url.encode('utf-8'), 'mode' : str(mode), 'name' : 
name.encode('utf-8')}
     u = sys.argv[0] +'?' +urllib.urlencode(parameters)
-    xbmc.log('addDir url = ' +str(u))
+    #xbmc.log('addDir url = ' +str(u))
     ok = True
     liz = xbmcgui.ListItem(name, iconImage="DefaultFolder.png", 
thumbnailImage=iconimage)
-    liz.setInfo(type="Video", infoLabels={"Title": name})
+    if(date != ''):
+        liz.setInfo(type="Video", infoLabels={"Title": name, "Date": date})
+    else:
+        liz.setInfo(type="Video", infoLabels={"Title": name})
+    for key in extraInfo.keys():
+        liz.setProperty(key, extraInfo[key])
     ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, 
listitem=liz, isFolder=True)
     return ok
    
 
 def addLink(name,url,iconimage):
-    xbmc.log('addLink url = ' +str(url))
+    #xbmc.log('addLink url = ' +str(url))
     ok = True
     liz = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", 
thumbnailImage=iconimage)
     liz.setInfo(type="Video", infoLabels={ "Title": name})
     ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, 
listitem=liz)
+    
     return ok
 
 
-def findTitle(content, searchTag, attrs):
-    itemTitle = ''
-    titlePart1 = content.find(searchTag, attrs)                
-    if(titlePart1):
-        titlePart1Value = titlePart1.find('div', attrs={'class' : 'value'})    
            
-        if(titlePart1Value):
-            itemTitle = titlePart1Value.string
-    if(itemTitle == None):
-        itemTitle = ''
-    return itemTitle
-
-
-
-def login(cookieFile):
-
+def login():
     username = __addon__.getSetting('username')
-    xbmc.log('username: ' +username) 
+    xbmc.log('Logging in with username "%s"' %username)
     password = __addon__.getSetting('password')
     
-    cj = mechanize.LWPCookieJar()
-    
-    try:
-        xbmc.log('load cookie file')
-        #ignore_discard=True loads session cookies too
-        cj.load(cookieFile, ignore_discard=True)
-        browser.set_cookiejar(cj)
-        
-        xbmc.log('cookies loaded, checking if they are still valid...')
-        browser.open("https://www.s04tv.de";)
-        doc = browser.response().read()
-        
-        loginStatus = checkLogin(doc, username)
-        if(loginStatus == 0):
-            return True
-    #if cookie file does not exist we just keep going...
-    except IOError:
-        xbmc.log('Error loading cookie file. Trying to log in again.')
-        pass
-    
-    xbmc.log('Logging in')    
+    if(username == '' or password == ''):
+        xbmcgui.Dialog().ok(PLUGINNAME, __language__(30102), 
__language__(30103))
+        return False
         
-    browser.open("https://www.s04tv.de";)
-    #HACK: find out how to address form by name
-    browser.select_form(nr=0)
-    browser.form['username'] = username
-    browser.form['password'] = password
-    browser.submit()
-    
-    cj.save(cookieFile, ignore_discard=True)
+    loginparams = {'username_field' : username, 'password_field' : password}
+    loginurl = 'https://ssl.s04.tv/get_content.php?lang=TV&form=login&%s' 
%urllib.urlencode(loginparams)
+    loginresponse = getUrl(loginurl)
+    xbmc.log('login response: ' +loginresponse)
     
-    doc = browser.response().read()
-    loginStatus = checkLogin(doc, username)            
-    return loginStatus == 0
-    
-
-def checkLogin(doc, username):
-    
-    print 'checkLogin'
-    
-    matchLoginSuccessful = re.search('Sie sind angemeldet als', doc, 
re.IGNORECASE)
-    if(matchLoginSuccessful):
-        xbmc.log('login successful')
-        return 0
-    
-    matchLoginFailed = re.search('Anmeldung fehlgeschlagen', doc, 
re.IGNORECASE)
-    if(matchLoginFailed):
+    #loginresponse should look like this: 
({"StatusCode":"1","stat":"OK","UserData":{"SessionID":"...","Firstname":"...","Lastname":"...","Username":"lom","hasAbo":1,"AboExpiry":"31.07.14"},"out":"<form>...</form>"});
+    #remove (); from response
+    jsonstring = loginresponse[1:len(loginresponse) -2]
+    jsonResult = json.loads(jsonstring)
+    if(jsonResult['stat'] == "OK"):
+        userdata = jsonResult['UserData']
+        if(userdata['hasAbo'] == 1):
+            xbmc.log('login successful')
+            return True
+        else:
+            xbmc.log('no valid abo')
+            xbmcgui.Dialog().ok(PLUGINNAME, __language__(30100) %username, 
__language__(30101))
+            return False
+    else:
         xbmc.log('login failed')
         xbmcgui.Dialog().ok(PLUGINNAME, __language__(30100) %username, 
__language__(30101))
-        return 1
+        return False
     
-    matchLoginFailed = re.search('Bitte geben Sie Benutzername und Passwort 
ein', doc, re.IGNORECASE)
-    if(matchLoginFailed):
-        xbmc.log('no username or password')
-        xbmcgui.Dialog().ok(PLUGINNAME, __language__(30102), 
__language__(30103))
-        return 1
-    
-    #not logged in but we don't know the reason
-    xbmc.log('You are not logged in.')
-    #Guess we are not logged in
-    return 1
+
+def getUrl(url):
+        url = url.replace('&amp;','&')
+        xbmc.log('Get url: '+url)
+        req = urllib2.Request(url)
+        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; 
en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
+        response = urllib2.urlopen(req)
+        link=response.read()
+        response.close()
+        return link
     
 
+def num_gen(size=1, chars=string.digits):
+        return ''.join(random.choice(chars) for x in range(size))
 
-def runPlugin(doc):
+
+def runPlugin(url, doc):
     
     if mode==None or doc==None or len(doc)<1:
-        buildVideoList(doc)
+        buildHomeDir(url, doc)
        
     elif mode==1:
-        buildVideoList(doc)
+        buildHomeDir(url, doc)
             
     elif mode==2:
-        buildVideoLinks(doc,name)
+        buildSubDir(url, doc)
+        
+    elif mode==3:
+        buildSubSubDir(url, doc)
+        
+    elif mode == 4:
+        getVideoUrl(url, doc)
 
 
-print 'S04TV: start addon'
+xbmc.log('S04TV: start addon')
 
 params = parse_qs(urlparse(sys.argv[2]).query)
 url=None
@@ -309,25 +422,8 @@ print "Name: "+str(name)
 if(url == None):
     url = BASE_URL
 
-path = xbmc.translatePath('special://profile/addon_data/%s' %(PLUGINID))
-
-if not os.path.exists(path):
-    try:
-        os.makedirs(path)
-    except:
-        path = ''
-
-success = login(os.path.join(path, 'cookies.txt'))
-
-
-if(success):
-    browser.open(url)
-    doc = browser.response().read()
-    runPlugin(doc)
-else:
-    provideTestvideoDir()
 
+doc = getUrl(url)
+runPlugin(url, doc)
+#sort video items
 xbmcplugin.endOfDirectory(thisPlugin)
-    
-    
-
diff --git a/plugin.video.s04tv/resources/language/English/strings.xml 
b/plugin.video.s04tv/resources/language/English/strings.xml
index 57f092a..ba055c1 100644
--- a/plugin.video.s04tv/resources/language/English/strings.xml
+++ b/plugin.video.s04tv/resources/language/English/strings.xml
@@ -6,6 +6,10 @@
        <string id="30003">Next page</string>
        <string id="30004">Play test video</string>
        <string id="30005">Play video</string>
+       <string id="30006">Hide [FREE/EXCL] flag</string>
+       <string id="30007">Hide videos that require login</string>
+       <string id="30008">Video qualitiy</string>
+       <string id="30009">Hide date in title</string>
        
        <string id="30100">Login failed for user "%s".</string> 
        <string id="30101">Please validate your credentials in plugin 
settings.</string>
diff --git a/plugin.video.s04tv/resources/language/German/strings.xml 
b/plugin.video.s04tv/resources/language/German/strings.xml
index 6611415..57449ec 100644
--- a/plugin.video.s04tv/resources/language/German/strings.xml
+++ b/plugin.video.s04tv/resources/language/German/strings.xml
@@ -6,6 +6,10 @@
        <string id="30003">Nächste Seite</string>
        <string id="30004">Testvideo abspielen</string>
        <string id="30005">Video abspielen</string>
+       <string id="30006">[FREE/EXCL] flag ausblenden</string>
+       <string id="30007">Videos ausblenden, die einen Login 
benötigen</string>
+       <string id="30008">Video Qualität</string>
+       <string id="30009">Datum im Titel ausblenden</string>
        
        <string id="30100">Login fehlgeschlagen für Benutzer "%s".</string>
        <string id="30101">Überprüfe Deine Daten in den 
Plugin-Einstellungen.</string>
diff --git a/plugin.video.s04tv/resources/settings.xml 
b/plugin.video.s04tv/resources/settings.xml
index ae7446d..a3c638b 100644
--- a/plugin.video.s04tv/resources/settings.xml
+++ b/plugin.video.s04tv/resources/settings.xml
@@ -3,5 +3,9 @@
        <category label="General">
                <setting id="username" type="text" label="30000" default="" />
                <setting id="password" type="text" option="hidden" 
label="30001" enable="!eq(-1,)" default="" />
+               <setting id="hidefreeexclflag" type="bool" label="30006" 
default="false" />
+               <setting id="hideexclusivevideos" type="bool" label="30007" 
default="false" />
+               <setting id="hidedate" type="bool" label="30009" 
default="false" />
+               <setting id="videoquality" label="30008" type="labelenum" 
values="low400|low|high|hd" default="hd"/>
        </category>
 </settings>
\ No newline at end of file

-----------------------------------------------------------------------

Summary of changes:
 plugin.video.s04tv/addon.xml                       |   20 +-
 plugin.video.s04tv/changelog.txt                   |    6 +
 plugin.video.s04tv/default.py                      |  520 ++++++++++++--------
 .../resources/language/English/strings.xml         |    4 +
 .../resources/language/German/strings.xml          |    4 +
 plugin.video.s04tv/resources/settings.xml          |    4 +
 6 files changed, 336 insertions(+), 222 deletions(-)


hooks/post-receive
-- 
Plugins

------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to