def Main():
    print 'songsnepal Main'
    Menu = [('New Videos', BASE_URL + '/newvideos.html', Common.video_thumb,
             'browse'),
            ('Top Videos', BASE_URL + '/topvideos.html', Common.video_thumb,
             'browse')]
    MediaItems = []
    for Title, Url, Thumb, Mode in Menu:
        Mediaitem = MediaItem()
        Mediaitem.ListItem.setInfo('video', {'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        Mediaitem.Image = Thumb
        Mediaitem.Mode = Mode
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)

    data = Common.getURL(BASE_URL)
    data = unicode(data, 'utf-8', 'ignore')
    #print data
    ULCat = common.parseDOM(data, "ul", {"id": "ul_categories"})[0]
    #ULCat = common.parseDOM(data, "div", {"class": "categoriesdropped"})[0]
    Items = common.parseDOM(ULCat, "li")
    for Item in Items:
        Title = common.parseDOM(Item, "a")
        if not Title:
            continue
        Title = Title[0]

        Href = common.parseDOM(Item, "a", ret="href")
        if not Href:
            continue
        Href = Href[0]
        Mediaitem = MediaItem()
        Mediaitem.ListItem.setInfo('video', {'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        Mediaitem.Image = Common.video_thumb
        Mediaitem.Mode = 'browse2'
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Href + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def browselive(url=None):
    if not url:
        url = Common.args.url
    print 'npvideo browselive'
    data = Common.getURL(url)
    livetvicons = common.parseDOM(data, "div", attrs={"id": "rvid"})[0]
    items = common.parseDOM(livetvicons, "li")
    MediaItems = []
    for item in items:
        #print 'inside for'
        Mediaitem = MediaItem()
        Title = common.parseDOM(item, "a")
        if not Title:
            print 'no title'
            continue
        Title = Title[0]
        Title = common.replaceHTMLCodes(Title)
        Title = Title.encode('utf-8')
        Href = common.parseDOM(item, "a", ret="href")
        if not Href:
            print 'no href'
            continue
        Href = Href[0]
        Url = urllib.quote_plus(BASE_URL % Href)
        Mediaitem.Mode = 'playlive'
        Mediaitem.ListItem.setInfo('video', {'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Common.video_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
Exemplo n.º 3
0
def Main():
    print 'nepalicollections Main'
    Today = date.today()
    Yesterday = Today - timedelta(1)
    Menu = [
        ('Today', BASE_URL + POST_URL + '&Post=' + Today.strftime("%m/%d/%Y"),
         Common.video_thumb, 'browse'),
        ('Yesterday',
         BASE_URL + POST_URL + '&Post=' + Yesterday.strftime("%m/%d/%Y"),
         Common.video_thumb, 'browse'),
        ('Search By Date', '', Common.search_thumb, 'searchd'),
        ('Search By Name', '', Common.search_thumb, 'searchn')
    ]
    MediaItems = []
    for Title, Url, Thumb, Mode in Menu:
        Mediaitem = MediaItem()
        Mediaitem.ListItem.setInfo('video', {'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        Mediaitem.Image = Thumb
        Mediaitem.Mode = Mode
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + urllib.quote_plus(
            Url) + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def browselive(url=None):
    if not url:
        url = Common.args.url
    print 'npvideo browselive'
    data = Common.getURL(url)
    livetvicons = common.parseDOM(data, "div", attrs={ "id": "rvid"})[0]
    items = common.parseDOM(livetvicons, "li")
    MediaItems = []
    for item in items:
        #print 'inside for'
        Mediaitem = MediaItem()
        Title = common.parseDOM(item, "a")
        if not Title:
            print 'no title'
            continue
        Title = Title[0]
        Title = common.replaceHTMLCodes(Title)
        Title = Title.encode('utf-8')
        Href = common.parseDOM(item, "a", ret="href")
        if not Href:
            print 'no href'
            continue
        Href = Href[0]
        Url = urllib.quote_plus(BASE_URL % Href)
        Mediaitem.Mode = 'playlive'
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Common.video_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def Main():
    print 'songsnepal Main'
    Menu = [('New Videos', BASE_URL + '/newvideos.html', Common.video_thumb, 'browse'),
            ('Top Videos', BASE_URL + '/topvideos.html', Common.video_thumb, 'browse')]
    MediaItems = []
    for Title, Url, Thumb, Mode in Menu:
        Mediaitem = MediaItem()
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        Mediaitem.Image = Thumb
        Mediaitem.Mode = Mode
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)
        
    data = Common.getURL(BASE_URL)
    data = unicode(data, 'utf-8', 'ignore')
    #print data
    ULCat = common.parseDOM(data, "ul", {"id": "ul_categories"})[0]
    #ULCat = common.parseDOM(data, "div", {"class": "categoriesdropped"})[0]
    Items = common.parseDOM(ULCat, "li")
    for Item in Items:
        Title = common.parseDOM(Item, "a")
        if not Title:
            continue
        Title = Title[0]
        
        Href = common.parseDOM(Item, "a", ret="href")
        if not Href:
            continue
        Href = Href[0]
        Mediaitem = MediaItem()
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        Mediaitem.Image = Common.video_thumb
        Mediaitem.Mode = 'browse2'
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Href + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def browsenews():
    print 'canadanepal browsevident'
    data = Common.load_local_page('canadanepal.html')
    data = data.replace('\r\n', '').replace('\r', '').replace('\n', '')
    column = common.parseDOM(data, "td", attrs={ "width": "949", "class": "magin" })
    if not column:
        return
    column = column[0]
    innertable = common.parseDOM(column, "table", attrs={ "style": "border-collapse: collapse",
                                                         "bgcolor": "#c6c6c6", "border": "1",
                                                         "bordercolor": "#ffffff", "cellpadding": "3",
                                                         "cellspacing": "0",
                                                         "width": "691" })
    if not innertable:
        return
    innertable = innertable[0]
    valigntop = common.parseDOM(innertable, "tr", attrs={ "valign": "top"})
    if not valigntop:
        return
    content = valigntop[0]
    tds = common.parseDOM(content, "td")
    if not tds:
        return
    tds = tds[1]
    #print 'tds: ' + tds
    MediaItems = []
    itemsl2 = re.compile('[->]+(.+?)<a href="(.+?)"').findall(tds)
    if not itemsl2:
        return
    for Title, href in itemsl2:
        if not href:
            continue
        Title = common.stripTags(Title)
        #Title = Title.replace(' Click here', ''). replace(' Click Here', '')
        Title = Title.replace('Click Here', '').replace('ClickHere', '').replace('clickhere', '')
        Title = Title.replace('Click here', '').replace('Clickhere', '')
        Title = common.replaceHTMLCodes(Title)
        Title = Title.strip()        
        Title = Title.encode('utf-8')
        if Title == '':
            continue
        #print 'Url: ' + href
        print 'Title: ' + Title
        Url = urllib.quote_plus(href)
        Mediaitem = MediaItem()
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Common.video_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Mode = 'play'
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)
        
    Common.addDir(MediaItems)
def Main():
    print 'enternepal Main'
    Menu = [('Music Videos', BASE_URL + '/category/music-videos', Common.video_thumb, 'browse'),
            ('Video Gallery', BASE_URL + '/video-gallery', Common.video_thumb, 'browse')]
    MediaItems = []
    for Title, Url, Thumb, Mode in Menu:
        Mediaitem = MediaItem()
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        Mediaitem.Image = Thumb
        Mediaitem.Mode = Mode
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def Main():
    print 'npvideo main'
    data = Common.save_web_page(BASE_URL % HOME, 'npvideo.html')
    #data = Common.load_local_page('npvideo.html')
    menu = common.parseDOM(data, "div", attrs={"id": "nav"})[0]
    menuItems = common.parseDOM(menu, "li")
    MediaItems = []
    for menuItem in menuItems:
        Mediaitem = MediaItem()
        Title = common.parseDOM(menuItem, "a", ret="title")
        if not Title:
            altTitle = common.stripTags(menuItem)
            if altTitle == 'Live TV':
                Title = 'Live TV'
            elif altTitle == 'Home':
                Title = 'Home'
            else:
                continue
        else:
            Title = Title[0]
        Href = common.parseDOM(menuItem, "a", ret="href")
        if not Href:
            continue

        if Title == 'Live TV':
            Mediaitem.Mode = 'browselive'
            Href = Href[0]
            Url = urllib.quote_plus(BASE_URL % Href)
        elif Title == 'Home':
            Mediaitem.Mode = 'browsehome'
            Url = ''
        else:
            Mediaitem.Mode = 'browse'
            Href = Href[0]
            Url = urllib.quote_plus(BASE_URL % Href)
        Mediaitem.ListItem.setInfo('video', {'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        Mediaitem.Image = Common.search_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def Main():
    print 'npvideo main'
    data = Common.save_web_page(BASE_URL % HOME, 'npvideo.html')
    #data = Common.load_local_page('npvideo.html')
    menu = common.parseDOM(data, "div", attrs={ "id": "nav"})[0]
    menuItems = common.parseDOM(menu, "li")
    MediaItems = []
    for menuItem in menuItems:
        Mediaitem = MediaItem()
        Title = common.parseDOM(menuItem, "a", ret="title")
        if not Title:
            altTitle = common.stripTags(menuItem)
            if altTitle == 'Live TV':
                Title = 'Live TV'
            elif altTitle == 'Home':
                Title = 'Home'
            else:
                continue
        else:
            Title = Title[0] 
        Href = common.parseDOM(menuItem, "a", ret="href")
        if not Href:
            continue
        
        if Title == 'Live TV':
            Mediaitem.Mode = 'browselive'
            Href = Href[0]
            Url = urllib.quote_plus(BASE_URL % Href)
        elif Title == 'Home':
            Mediaitem.Mode = 'browsehome'
            Url = ''
        else:
            Mediaitem.Mode = 'browse'
            Href = Href[0]
            Url = urllib.quote_plus(BASE_URL % Href)
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        Mediaitem.Image = Common.search_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def browsesidebars():
    print 'canadanepal browsesidebars'
    data = Common.load_local_page('canadanepal.html')
    data = data.replace('\r\n', '').replace('\r', '').replace('\n', '')
    sidecolumns = common.parseDOM(data, "td", attrs={ "width": "160", "class": "magin" })
    Hrefs = []
    print 'sidecolumns: ' + str(len(sidecolumns))
    for Column in sidecolumns:
        #print 'column: ' + Column
        Links = re.compile('<a href="(.+?)" title="" target="_blank">(.+?)</a>').findall(Column)
        if Links:
            Hrefs.extend(Links)
    if Hrefs:
        MediaItems = []
        for Url, Title in Hrefs:            
            Image = common.parseDOM(Title, "img", ret="src")
            if Image:
                Image = BASE_URL + Image[0]
            else:
                Image = Common.search_thumb
            Title = common.replaceHTMLCodes(Title)
            Title = common.stripTags(Title)
            Title = Title.encode('utf-8')
            Title = Title.replace('Watch ', '').replace('More ', '').replace('+ ', '')
            Title = Title.strip()
            
            if Title == '' or 'canadanepal' not in Url or ' Radio' in Title or 'FM' in Title:
                continue
            print 'Url: ' + Url
            print 'Title: ' + Title
            Mediaitem = MediaItem()
            Mediaitem.ListItem.setInfo('video', { 'Title': Title})
            Mediaitem.ListItem.setLabel(Title)
            Mediaitem.Isfolder = True
            Mediaitem.Image = Image
            Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
            if 'category' in Url:
                Mediaitem.Mode = 'browse'
            else:
                Mediaitem.Mode = 'play'
            Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
            Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
            MediaItems.append(Mediaitem)
        Common.addDir(MediaItems)
Exemplo n.º 11
0
def browse(url=None):
    if not url:
        url = Common.args.url
    print 'nepalicollections browse'
    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    splits = url.split("&Post=")
    url = splits[0]
    post = splits[1]
    postdict = {}
    if (re.match("\d\d/\d\d/\d\d\d\d", post)):
        postdict["stype"] = "date"
        postdict["searchtext"] = urllib.quote_plus(post)
    else:
        postdict["stype"] = "name"
        postdict["searchtext"] = post
    postdict["func"] = "searchdaily"

    data = Common.fetch(url, postdict)
    #print data
    responseJson = json.loads(data)
    items = responseJson["records"]
    MediaItems = []
    for menuItem in items:
        Mediaitem = MediaItem()
        Title = menuItem["title"]
        ID = menuItem["dailylinkid"]
        Href = BASE_URL + DETAIL_URL + ID
        Mediaitem.Mode = 'play'
        Url = urllib.quote_plus(Href)
        #print Url
        Date = menuItem["date"]
        Mediaitem.ListItem.setInfo('video', {'Title': Title, 'Plot': Date})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Common.video_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)

    Common.addDir(MediaItems)
    Common.SetViewMode()
def browse(url=None):
    if not url:
        url = Common.args.url
    print "nepalicollections browse"
    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), "movies")
    splits = url.split("&Post=")
    url = splits[0]
    post = splits[1]
    postdict = {}
    if re.match("\d\d/\d\d/\d\d\d\d", post):
        postdict["stype"] = "date"
        postdict["searchtext"] = urllib.quote_plus(post)
    else:
        postdict["stype"] = "name"
        postdict["searchtext"] = post
    postdict["func"] = "searchdaily"

    data = Common.fetch(url, postdict)
    # print data
    responseJson = json.loads(data)
    items = responseJson["records"]
    MediaItems = []
    for menuItem in items:
        Mediaitem = MediaItem()
        Title = menuItem["title"]
        ID = menuItem["dailylinkid"]
        Href = BASE_URL + DETAIL_URL + ID
        Mediaitem.Mode = "play"
        Url = urllib.quote_plus(Href)
        # print Url
        Date = menuItem["date"]
        Mediaitem.ListItem.setInfo("video", {"Title": Title, "Plot": Date})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Common.video_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty("IsPlayable", "true")
        MediaItems.append(Mediaitem)

    Common.addDir(MediaItems)
    Common.SetViewMode()
def Main():
    print 'canadanepal main'
    data = Common.save_web_page(BASE_URL, 'canadanepal.html')
    #data = Common.load_local_page('canadanepal.html')
    Menu = [('Video Entertainment', '', 'http://canadanepal.info/images/video.gif', 'browsevident'),
            ('Nepali News and Kura Kani', '', 'http://canadanepal.info/images/banner/samachar20.jpg', 'browsenews'),
            ('Sidebar Links', '', Common.topics_thumb, 'browsesidebars')]
    MediaItems = []
    for Title, Url, Thumb, Mode in Menu:
        Mediaitem = MediaItem()
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        Mediaitem.Image = Thumb
        Mediaitem.Mode = Mode
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def browsehome():
    print 'npvideo browsehome'
    data = Common.load_local_page('npvideo.html')
    latestvideodiv = common.parseDOM(data,
                                     "div",
                                     attrs={"id": "recentvidlist"})[0]
    items = common.parseDOM(latestvideodiv, "li")
    MediaItems = []
    for item in items:
        #print 'inside for'
        Mediaitem = MediaItem()
        Title = common.parseDOM(item, "a", ret="title")
        if not Title:
            print 'no title'
            continue
        Title = Title[0]
        Title = common.replaceHTMLCodes(Title)
        Title = Title.encode('utf-8')
        #Title = Title.encode('ascii', 'ignore')
        #print Title
        Href = common.parseDOM(item, "a", ret="href")
        if not Href:
            print 'no href'
            continue
        Href = Href[0]
        Href = common.replaceHTMLCodes(Href)
        Href = Href.encode('utf-8')
        Url = urllib.quote_plus(BASE_URL % Href)
        Mediaitem.Mode = 'play'
        Mediaitem.ListItem.setInfo('video', {'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Common.video_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        #Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def browse(url=None):
    if not url:
        url = Common.args.url
    print 'canadanepal browse'
    data = Common.getURL(url)
    listviewbox = common.parseDOM(data, "div", attrs={ "class": "listviewbox"})[0]
    videolist = common.parseDOM(listviewbox, "li")
    MediaItems = []
    for video in videolist:
        Mediaitem = MediaItem()
        Title = common.parseDOM(video, "span")
        if not Title:
            continue
        Title = Title[0] 
        Title = common.replaceHTMLCodes(Title)
        Title = Title.encode('utf-8')
        Href = common.parseDOM(video, "a", ret="href")
        if not Href:
            continue
        Href = Href[0]
        Href = common.replaceHTMLCodes(Href)
        Href = Href.encode('utf-8')
        Url = urllib.quote_plus(Href)
        Image = common.parseDOM(video, "img", ret="src")
        if Image:
            Image = Image[0]
        else:
            Image = Common.video_thumb
        Mediaitem.Mode = 'play'
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Image
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        #Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    
    Common.addDir(MediaItems)
def Main():
    print "nepalicollections Main"
    Today = date.today()
    Yesterday = Today - timedelta(1)
    Menu = [
        ("Today", BASE_URL + POST_URL + "&Post=" + Today.strftime("%m/%d/%Y"), Common.video_thumb, "browse"),
        ("Yesterday", BASE_URL + POST_URL + "&Post=" + Yesterday.strftime("%m/%d/%Y"), Common.video_thumb, "browse"),
        ("Search By Date", "", Common.search_thumb, "searchd"),
        ("Search By Name", "", Common.search_thumb, "searchn"),
    ]
    MediaItems = []
    for Title, Url, Thumb, Mode in Menu:
        Mediaitem = MediaItem()
        Mediaitem.ListItem.setInfo("video", {"Title": Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        Mediaitem.Image = Thumb
        Mediaitem.Mode = Mode
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + urllib.quote_plus(Url) + '"&name="' + Title + '"'
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def browsehome():
    print 'npvideo browsehome'
    data = Common.load_local_page('npvideo.html')
    latestvideodiv = common.parseDOM(data, "div", attrs={ "id": "recentvidlist"})[0]
    items = common.parseDOM(latestvideodiv, "li")
    MediaItems = []
    for item in items:
        #print 'inside for'
        Mediaitem = MediaItem()
        Title = common.parseDOM(item, "a", ret="title")
        if not Title:
            print 'no title'
            continue
        Title = Title[0]
        Title = common.replaceHTMLCodes(Title)
        Title = Title.encode('utf-8')
        #Title = Title.encode('ascii', 'ignore')
        #print Title
        Href = common.parseDOM(item, "a", ret="href")
        if not Href:
            print 'no href'
            continue
        Href = Href[0]
        Href = common.replaceHTMLCodes(Href)
        Href = Href.encode('utf-8')        
        Url = urllib.quote_plus(BASE_URL % Href)
        Mediaitem.Mode = 'play'
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Common.video_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        #Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
def browse(url=None):
    if not url:
        url = Common.args.url
    data = Common.getURL(url)
    items = common.parseDOM(data, "div", attrs={"class": "ui-corner-all"})
    MediaItems = []
    for item in items:
        Mediaitem = MediaItem()
        Title = common.parseDOM(item, "b", attrs={"class": "Title1"})[0]
        Image = common.parseDOM(item, "img", ret="src")[0]
        Href = common.parseDOM(item, "a", ret="href")[0]
        Url = urllib.quote_plus(Href)
        Artist = re.compile('Artist Name:.+?>(.+?)<').findall(item)
        if not Artist:
            Artist = ''
        else:
            Artist = Artist[0].strip()
        Album = re.compile('Album:.+?>(.+?)<').findall(item)
        if not Album:
            Album = ''
        else:
            Album = Album[0].strip()
        Plot = 'Artist: ' + Artist + '\n'
        Plot += 'Album: ' + Album
        Mediaitem.Mode = 'play'
        Mediaitem.ListItem.setInfo('video', {'Title': Title, 'Plot': Plot})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Image
        #print Mediaitem.Image
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    current = common.parseDOM(data,
                              "font",
                              attrs={"class": "next-pre-current"})[0]
    currenti = int(current)
    nexti = currenti + 1
    Next = re.compile(
        "<a href='(.+?)' class='next-pre' >([\d]{0,})</a>").findall(data)
    found = None
    #print 'len of next: ' + str(len(Next))
    for href, num in Common.Unique(Next):
        #print 'next: ' + str(nexti)
        #print 'num: ' + num
        if int(num) != nexti:
            continue
        Mediaitem = MediaItem()
        Title = 'Next'
        Url = urllib.quote_plus(BASE_URL + href)
        Mediaitem.Image = Common.next_thumb
        Mediaitem.Mode = 'browse'
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setInfo('video', {'Title': Title})
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        MediaItems.append(Mediaitem)
        found = True
    if not found:
        Next = common.parseDOM(data,
                               "a",
                               attrs={"class": "navlink"},
                               ret="href")[0]
        Mediaitem = MediaItem()
        Title = 'Next'
        Url = urllib.quote_plus(BASE_URL + Next)
        Mediaitem.Image = Common.next_thumb
        Mediaitem.Mode = 'browse'
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setInfo('video', {'Title': Title})
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
    Common.SetViewMode()
def browse(url=None):
    if not url:
        url = Common.args.url
    print 'songsnepal browse'
    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    
    data = Common.getURL(url)
    Items = common.parseDOM(data, "tr", {"class": "row\d"})
    MediaItems = []
    for Item in Items:
        Image = common.parseDOM(Item, "img", ret="src")
        if not Image:
            Image = ''
        else:
            Image = Image[0]
        
        TDS = common.parseDOM(Item, "td")
        if not "topvideos" in url:
            TDS = TDS[0]
        
            Artist = TDS.split("<td>", 1)[0]
        
            Title = common.parseDOM(TDS, "a")
            if not Title:
                continue
            Title = Title[0]
        
            Href = common.parseDOM(TDS, "a", ret="href")
            if not Href:
                continue
            Href = Href[0]
        
            Detail = TDS.rsplit(">", 1)[1]
        else:
            Artist = TDS[1]
            Title = common.parseDOM(TDS[2], "a")
            if not Title:
                continue
            Title = Title[0]
            Href = common.parseDOM(TDS[2], "a", ret="href")
            if not Href:
                continue
            Href = Href[0]
            Detail = TDS[3]
            
        Plot = "Artist: " + Artist
        Plot += "\n" + Detail
        
        Mediaitem = MediaItem()
        
        Mediaitem.Mode = 'play'
        Url = urllib.quote_plus(Href)
        Mediaitem.ListItem.setInfo('video', { 'Title': Title, 'Plot': Plot})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Image
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
        
    # Next Page
    pagination = common.parseDOM(data, "div", {"class": "pagination"})
    if pagination:
        div = pagination[0]
        Matches = re.compile('href="(.+?)">(.+?)<').findall(div)
        for Href, Title in Matches:
            if Title != "next &raquo;":
                continue            
            
            Mediaitem = MediaItem()
            Title = 'Next'
            Url = urllib.quote_plus(BASE_URL + '/' + Href)
            Mediaitem.Image = Common.next_thumb
            Mediaitem.Mode = 'browse'
            Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
            Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
            Mediaitem.ListItem.setInfo('video', { 'Title': Title})
            Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
            Mediaitem.ListItem.setLabel(Title)
            Mediaitem.Isfolder = True
            MediaItems.append(Mediaitem)
            
    Common.addDir(MediaItems)
    Common.SetViewMode()
Exemplo n.º 20
0
def browse():
    try:
        StartIndex = int(Common.args.startindex)
    except:
        StartIndex = 1
    Url = URL % (Query, StartIndex)
    Data = cache.cacheFunction(Common.getURL, Url)
    channel = common.parseDOM(Data, "channel")
    if not channel:
        return

    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')

    channel = channel[0]
    MediaItems = []
    totalResults = common.parseDOM(channel, "openSearch:totalResults")
    if totalResults:
        totalResults = int(totalResults[0])
        NextStart = StartIndex + 25
        if NextStart < totalResults:
            Mediaitem = MediaItem()  # Add a link to next page
            Title = 'Next Page'
            Mediaitem.Mode = 'browse'
            Mediaitem.Url = sys.argv[
                0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
            Mediaitem.Url += '"&startindex="' + str(
                NextStart) + '"&name="' + Title + '"'
            Mediaitem.ListItem.setLabel(Title)
            Mediaitem.Image = Common.next_thumb
            Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
            Mediaitem.Isfolder = True
            MediaItems.append(Mediaitem)

    items = common.parseDOM(channel, "item")
    if not items:
        return
    for item in items:
        Mediaitem = MediaItem()  # Add the items
        Title = common.parseDOM(item, "title")
        if not Title:
            continue
        Title = Title[0]

        Href = common.parseDOM(item, "link")
        if not Href:
            continue
        Href = Href[0]

        Image = re.compile('&lt;img.+?src="(.+?)"&gt;').findall(item)
        if not Image:
            Image = ''
        else:
            Image = Image[0]

        Desc = re.compile('&gt;([^&\r\n].+?)&lt;/a&gt;').findall(item)
        if not Desc:
            Desc = ''
        else:
            Desc = Desc[0]
        Desc = common.replaceHTMLCodes(Desc)
        Mediaitem.Mode = 'play'
        Mediaitem.Image = Image
        Hrefz = urllib.quote_plus(Href)
        Mediaitem.ListItem.setInfo('video', {'Title': Title, 'Plot': Desc})
        Mediaitem.ListItem.setLabel(Title)

        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Hrefz + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        MediaItems.append(Mediaitem)

    Common.addDir(MediaItems)
    Common.SetViewMode()
def browse(url=None):
    if not url:
        url = Common.args.url
    print 'npvideo browse'
    #data = Common.save_web_page(url, 'npvidcat.html')
    #data = Common.load_local_page('npvidcat.html')
    data = Common.getURL(url)
    videolistdiv = common.parseDOM(data,
                                   "div",
                                   attrs={"id": "categoryvidlist"})[0]
    videolist = common.parseDOM(videolistdiv, "li")
    MediaItems = []
    for video in videolist:
        Mediaitem = MediaItem()
        Title = common.parseDOM(video, "a", ret="title")
        if not Title:
            continue
        Title = Title[0]
        Title = common.replaceHTMLCodes(Title)
        Title = Title.encode('utf-8')
        Href = common.parseDOM(video, "a", ret="href")
        if not Href:
            continue
        Href = Href[0]
        Href = common.replaceHTMLCodes(Href)
        Href = Href.encode('utf-8')
        Url = urllib.quote_plus(BASE_URL % Href)
        Mediaitem.Mode = 'play'
        Mediaitem.ListItem.setInfo('video', {'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Common.search_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        #Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)

    right = common.parseDOM(videolistdiv, "div", attrs={"class": "right"})
    if right:
        right = right[0]
        selected = common.parseDOM(right, "span", attrs={"class": "selected"})
        if selected:
            selected = selected[0]
            selected = int(selected)
            nextPage = selected + 1
            pages = re.compile(
                "<a href='(.+?)' class='bound' title=.+?>([\d]{0,})</a>"
            ).findall(right)
            for href, num in pages:
                if int(num) == nextPage:
                    # Add next page
                    Mediaitem = MediaItem()
                    Title = 'Next'
                    Url = urllib.quote_plus(BASE_URL % href)
                    Mediaitem.Image = Common.next_thumb
                    Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
                    Mediaitem.Mode = 'browse'
                    Mediaitem.ListItem.setInfo('video', {'Title': Title})
                    Mediaitem.ListItem.setLabel(Title)
                    Mediaitem.Isfolder = True
                    Mediaitem.Url = sys.argv[
                        0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
                    Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
                    MediaItems.append(Mediaitem)
                    break

    Common.addDir(MediaItems)
Exemplo n.º 22
0
def browse(url=None):
    if not url:
        url = Common.args.url
    print 'nepalisongs browse'
    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')

    data = Common.getURL(url)
    #data = Common.save_web_page(url, 'nepalisongs.html')
    #data = Common.load_local_page('npvideo.html')
    data = unicode(data, 'utf-8', 'ignore')
    videolist = common.parseDOM(data, "ul", attrs={"class":
                                                   "top-videos-list"})[0]
    menuItems = common.parseDOM(videolist, "li")
    MediaItems = []
    for menuItem in menuItems:
        Mediaitem = MediaItem()
        spans = common.parseDOM(menuItem, "span")
        if len(spans) == 3:
            Artist = spans[0]
            #print Artist
            Title = spans[1]
            Title = common.stripTags(Title)
            Detail = Artist + '\n' + spans[2]
        else:
            continue

        Href = common.parseDOM(menuItem, "a", ret="href")
        if not Href:
            continue
        Mediaitem.Mode = 'play'
        Href = Href[0]
        Url = urllib.quote_plus(Href)
        Mediaitem.ListItem.setInfo('video', {
            'Title': Title,
            'Artist': Artist,
            'Plot': Detail
        })
        Mediaitem.ListItem.setLabel(Title)
        Img = common.parseDOM(menuItem, "img", ret="src")
        if Img:
            Mediaitem.Image = Img[0]
        else:
            Mediaitem.Image = Common.video_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    # Next Page
    pagination = common.parseDOM(data, "div", attrs={"class": "pagination"})[0]
    nextHref = re.compile('href="([^"]+)">next').findall(pagination)
    if nextHref:
        Href = nextHref[0]
        Href = common.replaceHTMLCodes(Href)
        Mediaitem = MediaItem()
        Title = 'Next'
        Url = urllib.quote_plus(HOME_URL + Href)
        Mediaitem.Image = Common.next_thumb
        Mediaitem.Mode = 'browse'
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setInfo('video', {'Title': Title})
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
    Common.SetViewMode()
def browse(url=None):
    if not url:
        url = Common.args.url
    print 'npvideo browse'
    #data = Common.save_web_page(url, 'npvidcat.html')
    #data = Common.load_local_page('npvidcat.html')
    data = Common.getURL(url)
    videolistdiv = common.parseDOM(data, "div", attrs={ "id": "categoryvidlist"})[0]
    videolist = common.parseDOM(videolistdiv, "li")
    MediaItems = []
    for video in videolist:
        Mediaitem = MediaItem()
        Title = common.parseDOM(video, "a", ret="title")
        if not Title:
            continue
        Title = Title[0] 
        Title = common.replaceHTMLCodes(Title)
        Title = Title.encode('utf-8')
        Href = common.parseDOM(video, "a", ret="href")
        if not Href:
            continue
        Href = Href[0]
        Href = common.replaceHTMLCodes(Href)
        Href = Href.encode('utf-8')
        Url = urllib.quote_plus(BASE_URL % Href)     
        Mediaitem.Mode = 'play'
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Common.search_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        #Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    
    right = common.parseDOM(videolistdiv, "div", attrs={ "class": "right"})
    if right:
        right = right[0]
        selected = common.parseDOM(right, "span", attrs={ "class": "selected" })
        if selected:
            selected = selected[0]
            selected = int(selected)
            nextPage = selected + 1
            pages = re.compile("<a href='(.+?)' class='bound' title=.+?>([\d]{0,})</a>").findall(right)
            for href, num in pages:
                if int(num) == nextPage:
                    # Add next page
                    Mediaitem = MediaItem()
                    Title = 'Next'
                    Url = urllib.quote_plus(BASE_URL % href)
                    Mediaitem.Image = Common.next_thumb   
                    Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
                    Mediaitem.Mode = 'browse'
                    Mediaitem.ListItem.setInfo('video', { 'Title': Title})
                    Mediaitem.ListItem.setLabel(Title)
                    Mediaitem.Isfolder = True
                    Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
                    Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
                    MediaItems.append(Mediaitem)    
                    break
    
    Common.addDir(MediaItems)    
def browse(url=None):
    if not url:
        url = Common.args.url
    data = Common.getURL(url)
    items = common.parseDOM(data, "div", attrs={ "class": "ui-corner-all"})
    MediaItems = []
    for item in items:
        Mediaitem = MediaItem()
        Title = common.parseDOM(item, "b", attrs={ "class": "Title1"})[0]
        Image = common.parseDOM(item, "img", ret="src")[0]
        Href = common.parseDOM(item, "a", ret="href")[0]
        Url = urllib.quote_plus(Href)
        Artist = re.compile('Artist Name:.+?>(.+?)<').findall(item)
        if not Artist:
            Artist = ''
        else:
            Artist = Artist[0].strip()
        Album = re.compile('Album:.+?>(.+?)<').findall(item)
        if not Album:
            Album = ''
        else:
            Album = Album[0].strip()
        Plot = 'Artist: ' + Artist + '\n'
        Plot += 'Album: ' + Album
        Mediaitem.Mode = 'play'
        Mediaitem.ListItem.setInfo('video', { 'Title': Title, 'Plot': Plot})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Image
        #print Mediaitem.Image
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    current = common.parseDOM(data, "font", attrs={ "class": "next-pre-current"})[0]
    currenti = int(current)
    nexti = currenti + 1
    Next = re.compile("<a href='(.+?)' class='next-pre' >([\d]{0,})</a>").findall(data)
    found = None
    #print 'len of next: ' + str(len(Next))
    for href, num in Common.Unique(Next):
        #print 'next: ' + str(nexti)
        #print 'num: ' + num
        if int(num) != nexti:
            continue
        Mediaitem = MediaItem()
        Title = 'Next'
        Url = urllib.quote_plus(BASE_URL + href)
        Mediaitem.Image = Common.next_thumb
        Mediaitem.Mode = 'browse'
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        MediaItems.append(Mediaitem)
        found = True
    if not found:
        Next = common.parseDOM(data, "a", attrs={ "class": "navlink" }, ret="href")[0]
        Mediaitem = MediaItem()
        Title = 'Next'
        Url = urllib.quote_plus(BASE_URL + Next)
        Mediaitem.Image = Common.next_thumb
        Mediaitem.Mode = 'browse'
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
    Common.SetViewMode()
def browse(url=None):
    if not url:
        url = Common.args.url
    print 'enternepal browse'
    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    
    data = Common.getURL(url)
    #data = Common.save_web_page(url, 'nepalisongs.html')
    #data = Common.load_local_page('npvideo.html')
    videolist = common.parseDOM(data, "div", attrs={ "class": "category_video.*?"})    
    MediaItems = []
    for menuItem in videolist:
        Href = common.parseDOM(menuItem, "a", ret="href")
        if not Href:
            continue
        Href = Href[0]
        
        Image = common.parseDOM(menuItem, "img", ret="src")
        if not Image:
            Image = ''
        else:
            Image = Image[0]
            
        Title = common.parseDOM(menuItem, "img", ret="title")
        if not Title:
            continue
        Title = Title[0]
        Title = common.replaceHTMLCodes(Title)
        
        Plot = common.parseDOM(menuItem, "div", {"class": "title"})
        if not Plot:
            Plot = ''
        else:
            Plot = Plot[0]
            
        Mediaitem = MediaItem()
        
        Mediaitem.Mode = 'play'
        Url = urllib.quote_plus(Href)
        Mediaitem.ListItem.setInfo('video', { 'Title': Title, 'Plot': Plot})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Image
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    # Next Page
    pagination = common.parseDOM(data, "a", { "class": "nextpostslink" }, ret="href")
    if pagination:
        Href = pagination[0]
        Href = common.replaceHTMLCodes(Href)
        Mediaitem = MediaItem()
        Title = 'Next'
        Url = urllib.quote_plus(Href)
        Mediaitem.Image = Common.next_thumb
        Mediaitem.Mode = 'browse'
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
    Common.SetViewMode()
def browse(url=None):
    if not url:
        url = Common.args.url
    print 'nepalisongs browse'
    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    
    data = Common.getURL(url)
    #data = Common.save_web_page(url, 'nepalisongs.html')
    #data = Common.load_local_page('npvideo.html')
    data = unicode(data, 'utf-8', 'ignore')
    videolist = common.parseDOM(data, "ul", attrs={ "class": "top-videos-list"})[0]
    menuItems = common.parseDOM(videolist, "li")
    MediaItems = []
    for menuItem in menuItems:
        Mediaitem = MediaItem()
        spans = common.parseDOM(menuItem, "span")
        if len(spans) == 3:
            Artist = spans[0]
            #print Artist
            Title = spans[1]
            Title = common.stripTags(Title)
            Detail = Artist + '\n' + spans[2]
        else:
            continue
         
        Href = common.parseDOM(menuItem, "a", ret="href")
        if not Href:
            continue
        Mediaitem.Mode = 'play'
        Href = Href[0]
        Url = urllib.quote_plus(Href)
        Mediaitem.ListItem.setInfo('video', { 'Title': Title, 'Artist': Artist, 'Plot': Detail})
        Mediaitem.ListItem.setLabel(Title)
        Img = common.parseDOM(menuItem, "img", ret="src")
        if Img:
            Mediaitem.Image = Img[0]
        else:
            Mediaitem.Image = Common.video_thumb
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)
    # Next Page
    pagination = common.parseDOM(data, "div", attrs={ "class": "pagination" })[0]
    nextHref = re.compile('href="([^"]+)">next').findall(pagination)
    if nextHref:
        Href = nextHref[0]
        Href = common.replaceHTMLCodes(Href)
        Mediaitem = MediaItem()
        Title = 'Next'
        Url = urllib.quote_plus(HOME_URL + Href)
        Mediaitem.Image = Common.next_thumb
        Mediaitem.Mode = 'browse'
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setInfo('video', { 'Title': Title})
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Isfolder = True
        MediaItems.append(Mediaitem)
    Common.addDir(MediaItems)
    Common.SetViewMode()
def browse(url=None):
    if not url:
        url = Common.args.url
    print 'songsnepal browse'
    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')

    data = Common.getURL(url)
    Items = common.parseDOM(data, "tr", {"class": "row\d"})
    MediaItems = []
    for Item in Items:
        Image = common.parseDOM(Item, "img", ret="src")
        if not Image:
            Image = ''
        else:
            Image = Image[0]

        TDS = common.parseDOM(Item, "td")
        if not "topvideos" in url:
            TDS = TDS[0]

            Artist = TDS.split("<td>", 1)[0]

            Title = common.parseDOM(TDS, "a")
            if not Title:
                continue
            Title = Title[0]

            Href = common.parseDOM(TDS, "a", ret="href")
            if not Href:
                continue
            Href = Href[0]

            Detail = TDS.rsplit(">", 1)[1]
        else:
            Artist = TDS[1]
            Title = common.parseDOM(TDS[2], "a")
            if not Title:
                continue
            Title = Title[0]
            Href = common.parseDOM(TDS[2], "a", ret="href")
            if not Href:
                continue
            Href = Href[0]
            Detail = TDS[3]

        Plot = "Artist: " + Artist
        Plot += "\n" + Detail

        Mediaitem = MediaItem()

        Mediaitem.Mode = 'play'
        Url = urllib.quote_plus(Href)
        Mediaitem.ListItem.setInfo('video', {'Title': Title, 'Plot': Plot})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Image
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)

    # Next Page
    pagination = common.parseDOM(data, "div", {"class": "pagination"})
    if pagination:
        div = pagination[0]
        Matches = re.compile('href="(.+?)">(.+?)<').findall(div)
        for Href, Title in Matches:
            if Title != "next &raquo;":
                continue

            Mediaitem = MediaItem()
            Title = 'Next'
            Url = urllib.quote_plus(BASE_URL + '/' + Href)
            Mediaitem.Image = Common.next_thumb
            Mediaitem.Mode = 'browse'
            Mediaitem.Url = sys.argv[
                0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
            Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
            Mediaitem.ListItem.setInfo('video', {'Title': Title})
            Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
            Mediaitem.ListItem.setLabel(Title)
            Mediaitem.Isfolder = True
            MediaItems.append(Mediaitem)

    Common.addDir(MediaItems)
    Common.SetViewMode()
def browse2(url=None):
    if not url:
        url = Common.args.url
    print 'songsnepal browse2'
    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')

    data = Common.getURL(url)
    detailpage = common.parseDOM(data, "div", {"id": "detail_page"})[0]
    Items = common.parseDOM(detailpage, "li", {"class": "item column"})
    MediaItems = []
    for Item in Items:
        Href = common.parseDOM(Item, "a", ret="href")
        if not Href:
            continue
        Href = Href[0]

        Image = common.parseDOM(Item, "img", ret="src")
        if not Image:
            Image = ''
        else:
            Image = Image[0]

        Artist = common.parseDOM(Item, "em", {"class": "artist_name"})
        if not Artist:
            Artist = ''
        else:
            Artist = Artist[0]

        Title = common.parseDOM(Item, "em", {"class": "song_name"})
        if not Title:
            continue
        Title = Title[0]

        Mediaitem = MediaItem()

        Mediaitem.Mode = 'play'
        Url = urllib.quote_plus(Href)
        Mediaitem.ListItem.setInfo('video', {'Title': Title, 'Plot': Artist})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Image
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[
            0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
        Mediaitem.Url += '"&url="' + Href + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)

    # Next Page
    pagination = common.parseDOM(data, "div", {"class": "pagination"})
    if pagination:
        div = pagination[0]
        Matches = re.compile('href="(.+?)">(.+?)<').findall(div)
        for Href, Title in Matches:
            if Title != "next &raquo;":
                continue

            Mediaitem = MediaItem()
            Title = 'Next'
            Url = urllib.quote_plus(BASE_URL + '/' + Href)
            Mediaitem.Image = Common.next_thumb
            Mediaitem.Mode = 'browse2'
            Mediaitem.Url = sys.argv[
                0] + '?site="' + site + '"&mode="' + Mediaitem.Mode
            Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
            Mediaitem.ListItem.setInfo('video', {'Title': Title})
            Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
            Mediaitem.ListItem.setLabel(Title)
            Mediaitem.Isfolder = True
            MediaItems.append(Mediaitem)

    Common.addDir(MediaItems)
    Common.SetViewMode()
def browse():
    try:
        StartIndex = int(Common.args.startindex)
    except:
        StartIndex = 1
    Url = URL % (Query, StartIndex)
    Data = cache.cacheFunction(Common.getURL, Url)
    channel = common.parseDOM(Data, "channel")
    if not channel:
        return

    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    
    channel = channel[0]
    MediaItems = []
    totalResults = common.parseDOM(channel, "openSearch:totalResults")
    if totalResults:
        totalResults = int(totalResults[0])
        NextStart = StartIndex + 25
        if NextStart < totalResults:
            Mediaitem = MediaItem()    # Add a link to next page
            Title = 'Next Page'
            Mediaitem.Mode = 'browse'
            Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
            Mediaitem.Url += '"&startindex="' + str(NextStart) + '"&name="' + Title + '"'
            Mediaitem.ListItem.setLabel(Title)
            Mediaitem.Image = Common.next_thumb
            Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
            Mediaitem.Isfolder = True
            MediaItems.append(Mediaitem)
        
    items = common.parseDOM(channel, "item")
    if not items:
        return
    for item in items:
        Mediaitem = MediaItem()    # Add the items
        Title = common.parseDOM(item, "title")
        if not Title:
            continue
        Title = Title[0]
        
        Href = common.parseDOM(item, "link")
        if not Href:
            continue
        Href = Href[0]

        Image = re.compile('&lt;img.+?src="(.+?)"&gt;').findall(item)
        if not Image:
            Image = ''
        else:
            Image = Image[0]
        
        Desc = re.compile('&gt;([^&\r\n].+?)&lt;/a&gt;').findall(item)
        if not Desc:
            Desc = ''
        else:
            Desc = Desc[0]
        Desc = common.replaceHTMLCodes(Desc)
        Mediaitem.Mode = 'play'
        Mediaitem.Image = Image
        Hrefz = urllib.quote_plus(Href)
        Mediaitem.ListItem.setInfo('video', { 'Title': Title, 'Plot': Desc})
        Mediaitem.ListItem.setLabel(Title)
        
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Hrefz + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        MediaItems.append(Mediaitem)

    Common.addDir(MediaItems)    
    Common.SetViewMode()
def browse2(url=None):
    if not url:
        url = Common.args.url
    print 'songsnepal browse2'
    # set content type so library shows more views and info
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    
    data = Common.getURL(url)
    detailpage = common.parseDOM(data, "div", {"id": "detail_page"})[0]
    Items = common.parseDOM(detailpage, "li", {"class": "item column"})
    MediaItems = []
    for Item in Items:
        Href = common.parseDOM(Item, "a", ret="href")
        if not Href:
            continue
        Href = Href[0]
        
        Image = common.parseDOM(Item, "img", ret="src")
        if not Image:
            Image = ''
        else:
            Image = Image[0]
        
        Artist = common.parseDOM(Item, "em", {"class": "artist_name"})
        if not Artist:
            Artist = ''
        else:
            Artist = Artist[0]
            
        Title = common.parseDOM(Item, "em", {"class": "song_name"})
        if not Title:
            continue
        Title = Title[0]

        Mediaitem = MediaItem()
        
        Mediaitem.Mode = 'play'
        Url = urllib.quote_plus(Href)
        Mediaitem.ListItem.setInfo('video', { 'Title': Title, 'Plot': Artist})
        Mediaitem.ListItem.setLabel(Title)
        Mediaitem.Image = Image
        Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
        Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
        Mediaitem.Url += '"&url="' + Href + '"&name="' + Title + '"'
        Mediaitem.ListItem.setProperty('IsPlayable', 'true')
        MediaItems.append(Mediaitem)

    # Next Page
    pagination = common.parseDOM(data, "div", {"class": "pagination"})
    if pagination:
        div = pagination[0]
        Matches = re.compile('href="(.+?)">(.+?)<').findall(div)
        for Href, Title in Matches:
            if Title != "next &raquo;":
                continue            
            
            Mediaitem = MediaItem()
            Title = 'Next'
            Url = urllib.quote_plus(BASE_URL + '/' + Href)
            Mediaitem.Image = Common.next_thumb
            Mediaitem.Mode = 'browse2'
            Mediaitem.Url = sys.argv[0] + '?site="' + site + '"&mode="' + Mediaitem.Mode 
            Mediaitem.Url += '"&url="' + Url + '"&name="' + Title + '"'
            Mediaitem.ListItem.setInfo('video', { 'Title': Title})
            Mediaitem.ListItem.setThumbnailImage(Mediaitem.Image)
            Mediaitem.ListItem.setLabel(Title)
            Mediaitem.Isfolder = True
            MediaItems.append(Mediaitem)
            
    Common.addDir(MediaItems)
    Common.SetViewMode()