本文整理汇总了Python中utils.Utils.genMoreEnginScript方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.genMoreEnginScript方法的具体用法?Python Utils.genMoreEnginScript怎么用?Python Utils.genMoreEnginScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Utils
的用法示例。
在下文中一共展示了Utils.genMoreEnginScript方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Rss
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import genMoreEnginScript [as 别名]
class Rss(BaseExtension):
def __init__(self):
BaseExtension.__init__(self)
self.utils = Utils()
def excute(self, form_dict):
fileName = form_dict['fileName'].encode('utf8')
rID = form_dict['rID'].encode('utf8')
url = form_dict['url']
return self.genHtml(url, form_dict['divID'].encode('utf8'), rID)
def check(self, form_dict):
fileName = form_dict['fileName'].encode('utf8')
rID = form_dict['rID'].encode('utf8')
return fileName.find('rss/') != -1 and rID.startswith('loop') == False
def genHtml(self, feed_url, ref_divID, rID):
f = feedparser.parse( feed_url )
print "Feed Title %s" % f.feed.title
count = 0
html = ''
html += '<div class="ref"><ol>'
for entry in f.entries:
print "Title: %s" % entry.title
print "link: %s" % entry.link
count += 1
html += '<li><span>' + str(count) + '.</span>'
html += '<p><a target="_blank" href="' + entry.link + '"> '+ self.utils.formatTitle(entry.title, 60) + '</a>'
ref_divID += '-' + str(count)
linkID = 'a-' + ref_divID[ref_divID.find('-') + 1 :]
appendID = str(count)
script = self.utils.genMoreEnginScript(linkID, ref_divID, "loop-" + rID.replace(' ', '-') + '-' + str(appendID), entry.title, entry.link, '-')
html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', ref_divID, '', False);
html += '</p></li>'
html += '</ol></div>'
return html
示例2: Keyword
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import genMoreEnginScript [as 别名]
class Keyword(BaseExtension):
def __init__(self):
BaseExtension.__init__(self)
self.utils = Utils()
def excute(self, form_dict):
url = form_dict['url'].encode('utf8')
print url
selection = form_dict['selection']
print selection
keywords = []
keyword_dict = {}
if selection != None:
engins = ['google', 'bing', 'amazon', 'youtube']
for e in engins:
r = requests.get('http://tools.seochat.com/components/com_seotools/tools/suggest-tool/' + e + 'all.php?q=' + selection)
jobj = json.loads(r.text)
for item in jobj:
if type(item) != type([]) and item.find('fieldset>') == -1:
if keyword_dict.has_key(item.strip()) == False:
keyword_dict[item.strip()] = item.strip()
keywords.append(item.strip())
html = '<div class="ref"><ol>'
count = 0
ref_divID = form_dict['divID']
key = form_dict['rID']
for k in keywords:
count += 1
ref_divID += '-' + str(count)
linkID = 'a-' + ref_divID[ref_divID.find('-') + 1 :]
appendID = str(count)
script = self.utils.genMoreEnginScript(linkID, ref_divID, "loop-" + key.replace(' ', '-') + '-' + str(appendID), k, '', '-')
print k
html += '<li><span>' + str(count) + '.</span>'
html += '<p>' + self.utils.toSmartLink(k)
if script != '':
html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', ref_divID, '', False);
html +='</p></li>'
return html + '</ol></div>'
return 'nothing'
def check(self, form_dict):
return form_dict['rID'] != None and form_dict['rID'].startswith('loop') == False
示例3: Outline
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import genMoreEnginScript [as 别名]
class Outline(BaseExtension):
def __init__(self):
BaseExtension.__init__(self)
self.utils = Utils()
def excute(self, form_dict):
url = form_dict['url'].encode('utf8')
url = url.replace('#space', ' ')
divID = form_dict['divID']
rID = form_dict['rID']
cmd = './outline.py -i "' + url + '"'
output = subprocess.check_output(cmd, shell=True).strip()
html = '<div class="ref"><ol>'
count = 0
for line in output.split('\n'):
if line.strip() == '':
continue
count += 1
html += '<li><span>' + str(count) + '.</span>'
html += '<p>' + self.utils.toSmartLink(line.strip())
divID += '-' + str(count)
linkID = 'a-' + divID[divID.find('-') + 1 :]
appendID = str(count)
script = self.utils.genMoreEnginScript(linkID, divID, "loop-o-" + rID.replace(' ', '-') + '-' + str(appendID) , line, '', '-', hidenEnginSection=Config.bookmark_hiden_engin_section)
html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', divID, '', False);
html += '</p></li>'
html += '</ol></div>'
return html
def check(self, form_dict):
url = form_dict['url'].encode('utf8').strip()
print url
#print url.startswith('http') == False
print url != '' and url.startswith('http') == False and url.endswith('.pdf')
return url != '' and url.startswith('http') == False and url.endswith('.pdf')
示例4: Preview
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import genMoreEnginScript [as 别名]
#.........这里部分代码省略.........
texts.append(k.replace('%20', ' '))
if value.startswith('http'):
urls.append(value.replace('%s', k))
else:
urls.append(self.utils.toQueryUrl(self.utils.getEnginUrl(value), k))
return self.previewPages(texts, urls)
elif url.find(',') != -1:
urls = url.split(',')
return self.previewPages(urls, urls)
if url == '':
url = self.utils.toSmartLink(form_dict['rTitle'].encode('utf8'))
src = ''
width = str(int(screenWidth) / 3 + 50)
height = str(int(screenHeight) / 3 + 50)
column = form_dict['column']
if url.startswith('file') or url.startswith('/User'):
subprocess.check_output("/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome " + url, shell=True)
return 'ok'
if column == '1':
width = str(int(screenWidth) - 70)
height = str(int(screenHeight) - 150)
elif column == '2':
width = str(int(screenWidth) / 2 - 20)
height = str(int(screenHeight) / 2 - 50)
if url.find('youtube') != -1 and url.find('watch') != -1:
src = "https://www.youtube.com/embed/" + url[url.rfind('v=') + 2 :]
if column == '1':
width = str(int(screenWidth) / 3 + 200)
height = str(int(screenHeight) / 2)
elif url.find('163') != -1:
src = url.replace('open', 'v')
elif rID.find('arxiv') != -1:
arxiv_id = rID[rID.find('arxiv-') + 6 :].replace('-', '.')
version = self.utils.get_last_arxiv_version(arxiv_id)
src = 'http://arxiv.org/pdf/' + arxiv_id + version
else:
src = url
if self.utils.suportFrame(url, 5) == False:
return url
html = '<div class="ref"><br><iframe width="' + width + '" height="' + height + '" src="' + self.getUrl(src) + '" frameborder="0" allowfullscreen></iframe>'
if url.find('youtube') != -1 and url.find('watch') != -1:
r = requests.get(url)
soup = BeautifulSoup(r.text)
div = soup.find('div', id='watch-uploader-info')
div2 = soup.find('div', id='watch-description-text')
div_watch = soup.find('div', class_='watch-view-count')
div_user = soup.find('div', class_='yt-user-info')
text = div_user.text.strip()
html += '<br><br><div style="background-color:#F8F8FF; border-radius: 5px 5px 5px 5px; width:auto;">'
html += '<a target="_blank" href="' + 'https://www.youtube.com' + div_user.a['href'] + '">' + text+ '</a>'
count = 0
html += ' ' + div_watch.text.strip() + '<br>' +\
div.text.strip() + '<br>' + div2.text.strip() + '<br><br>'
for type in ['videos', 'playlists']:
ref_divID = form_dict['divID'].encode('utf8')
rID = form_dict['rID']
ref_divID += '-' + type
linkID = 'a-' + ref_divID[ref_divID.find('-') + 1 :]
appendID = count
count += 1
link = 'https://www.youtube.com' + div_user.a['href'] + '/' + type
script = self.utils.genMoreEnginScript(linkID, ref_divID, "loop-" + rID.replace(' ', '-') + '-' + str(appendID), text, link, '-')
if script != "":
html += '<div>'
html += '<a target="_blank" href="' + link + '">' + text + '</a>' + " 's " + type
if script != "":
html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', ref_divID, '', False);
html += '</div>'
html += '</div>'
return html + '</div>'
def getUrl(self, url):
'''
if 'weixin' in url:
r = requests.get(url)
soup = BeautifulSoup(r.text)
p = soup.find('p', class_='tit')
url = p.a['href']
print 'getUrl:' + url
'''
return url
def check(self, form_dict):
url = form_dict['url'].encode('utf8')
return url != None and url != '' and url.startswith('http') and url.find(Config.ip_adress) == -1 or url.find('[') != -1
示例5: Bookmark
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import genMoreEnginScript [as 别名]
#.........这里部分代码省略.........
if self.containIgoncase(jobj['url'].strip(), rTitle.replace(' ', '%20').strip()):
return True, ''
if self.containIgoncase(jobj['url'].strip(), rTitle.strip().replace(' ', '-')):
return True, ''
if self.containIgoncase(jobj['title'].strip(), rTitle.strip().replace(' ', '-')):
return True, rTitle.strip().replace(' ', '-')
return False, ''
def gen_item(self, rID, ref_divID, count, jobj, moreOption, orginFilename, keywords=[], higtLightText=''):
html = ''
html += '<li><span>' + str(count) + '.</span>'
url = ''
if jobj.has_key('url'):
url = jobj['url']
showText = self.utils.formatTitle(jobj['title'], Config.smart_link_br_len, keywords)
if higtLightText != '':
showText = self.utils.doHighLight(showText, higtLightText, appendValue=False)
if url != '':
html += '<p>' + self.utils.enhancedLink(url, self.utils.formatTitle(jobj['title'], Config.smart_link_br_len, keywords), module='bookmark', library=orginFilename, rid=rID, aid=rID, showText=showText) + self.utils.getIconHtml(url)
else:
html += '<p>' + showText + self.utils.getIconHtml(".dir", radius=False) #' > '
#if self.existChild(str(jobj['id'])):
# html += ' > '
if moreOption:
ref_divID += '-' + str(count)
linkID = 'a-' + ref_divID[ref_divID.find('-') + 1 :]
appendID = str(count)
script = self.utils.genMoreEnginScript(linkID, ref_divID, "loop-b-" + rID.replace(' ', '-') + '-' + str(appendID) + '-' + str(jobj['id']), jobj['title'], url, '-', hidenEnginSection=Config.bookmark_hiden_engin_section)
descHtml = ''
if url != '':
descHtml = self.utils.genDescHtml('url:' + url, Config.course_name_len, self.tag.tag_list)
#print 'descHtml:' + descHtml
html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', ref_divID, '', False, descHtml=descHtml);
html += '</p></li>'
return html
def genWebsiteHtml(self, key, orginFilename):
html = '<ol>'
count = 0
cookies = dict(unsafe='True')
page = ''
page_num = 6
page = 'http://www.xmarks.com/topic/' + key
nextpage = ''
page_count = 0
for i in range(0, page_num):
page_count += 1
if nextpage != '':
page = nextpage.replace('2', str(page_count))
print 'request ' + page
r = requests.get(page, cookies=cookies)
if r.status_code != 200:
break
soup = BeautifulSoup(r.text)
#print r.text
示例6: History
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import genMoreEnginScript [as 别名]
#.........这里部分代码省略.........
html += urlIcon
#if jobj['desc'].strip().startswith('clickcount') == False and title.lower() != Config.history_quick_access_name.lower():
# html += self.utils.getIconHtml('', title='remark')
else:
html += '<p>' + title
html += linkCountHtml
if appendFrontHtml != '':
html += appendFrontHtml
html += ' > '
#if self.existChild(str(jobj['id'])):
# html += ' > '
if urlIcon == '' and resType != '' and Config.website_icons.has_key(resType):
html += self.utils.getIconHtml('', title=resType)
if appendAfterHtml != '':
html += appendAfterHtml
if moreOption:
linkID = self.getAID(ref_divID, count) + '-more'
ref_divID += '-' + str(count)
appendID = str(count)
originTitle = title
#if title.find(' - ') != -1:
# title = title[0 : title.find('-')].strip()
script = self.utils.genMoreEnginScript(linkID, ref_divID, itemID, title, url, originTitle, hidenEnginSection=Config.history_hiden_engin_section)
descHtml = ''
if jobj.has_key('desc') and jobj['desc'].strip() != '':
#print jobj['desc']
#refreshID = self.getRefreshID(self.divID, text=title)
refreshID = ''
aid = self.getAID(self.divID, count)
#print 'parentDesc--->' + jobj['parentDesc']
parentOfSearchin = '>' + title
if Config.history_enable_subitem_log:
descHtml = self.utils.genDescHtml(jobj['desc'], Config.course_name_len, self.tag.tag_list, library=fileName, rid=rID, aid=aid, refreshID=refreshID, iconKeyword=True, fontScala=1, parentDesc=jobj['parentDesc'], module='history', unfoldSearchin=False, parentOfSearchin=parentOfSearchin)
else:
descHtml = self.utils.genDescHtml(jobj['desc'], Config.course_name_len, self.tag.tag_list, iconKeyword=True, fontScala=1, rid=rID, aid=aid, refreshID=refreshID, parentDesc=jobj['parentDesc'], module='history', unfoldSearchin=False, parentOfSearchin=parentOfSearchin)
#if url != '':
# descHtml = self.utils.genDescHtml('url:' + url, Config.course_name_len, self.tag.tag_list)
#print 'descHtml:' + descHtml
#descHtml = '<br>' + descHtml
html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', ref_divID, '', False, descHtml=descHtml).strip();
html += '</p></li>'
return html
def getAID(self, ref_divID, count):
ref_divID += '-' + str(count)
linkID = 'a-' + ref_divID[ref_divID.find('-') + 1 :]
return linkID
示例7: Milestone
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import genMoreEnginScript [as 别名]
class Milestone(BaseExtension):
record_milestone = {}
html = ''
def __init__(self):
BaseExtension.__init__(self)
self.utils = Utils()
def loadMilestone(self, filename, rID):
print 'loadMilestone ' + filename
#if len(self.record_milestone) != 0 and self.record_milestone.has_key(rID):
# return
name = 'extensions/milestone/data/' + filename + '-milestone'
record_milestone_back = {}
if os.path.exists(name):
f = open(name, 'rU')
all_lines = f.readlines()
for line in all_lines:
if line.startswith('#'):
continue
record = Record(line)
key = record.get_id().strip()
if key != rID:
continue
if record_milestone_back.has_key(key):
record_milestone_back[key].append(record)
else:
record_milestone_back[key] = [record]
if record_milestone_back.has_key(rID) and len(record_milestone_back[rID]) > 0:
#if len(record_milestone_back[rID]) > 20:
record_milestone_back[rID] = reversed(record_milestone_back[rID])
self.record_milestone[rID] = record_milestone_back[rID]
#for (k, v) in self.record_milestone.items():
# print k
def excute(self, form_dict):
fileName = form_dict['fileName'].encode('utf8')
rID = form_dict['rID'].encode('utf8')
self.loadMilestone(self.formatFileName(fileName), rID)
#print self.record_milestone
if self.record_milestone.has_key(rID):
return self.genMilestoneHtml(rID, form_dict['divID'].encode('utf8'))
return 'not found'
def check(self, form_dict):
fileName = form_dict['fileName'].encode('utf8')
rID = form_dict['rID'].encode('utf8')
self.loadMilestone(self.formatFileName(fileName), rID)
return self.record_milestone.has_key(rID)
def genMilestoneHtml(self, rID, ref_divID):
return self.genMetadataHtml(rID, ref_divID)
def genMetadataHtml(self, key, ref_divID):
if self.record_milestone.has_key(key):
self.html = '<div class="ref"><ol>'
count = 0
print 'sdsd'
for r in self.record_milestone[key]:
count += 1
ref_divID += '-' + str(count)
linkID = 'a-' + ref_divID[ref_divID.find('-') + 1 :]
appendID = str(count)
script = self.utils.genMoreEnginScript(linkID, ref_divID, "loop-" + key.replace(' ', '-') + '-' + str(appendID), self.utils.clearHtmlTag(r.get_title().strip()), r.get_url().strip(), '-')
title = r.get_title().strip()
id = title[0 : title.find(' ')].strip()
self.html += '<li><span>' + id + '.</span>'
if len(id) > 4:
self.html += '<br>'
if script != "" and len(title[title.find(' ') + 1 :].strip()) < 20:
self.html += '<p>' + self.utils.toSmartLink(title[title.find(' ') + 1 :].strip())
self.html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', ref_divID, '', False);
else:
self.html += '<p>' + title[title.find(' ') + 1 :].strip()
self.html += '</p></li>'
return self.html + "</ol></div>"
else:
return ''
示例8: Filefinder
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import genMoreEnginScript [as 别名]
#.........这里部分代码省略.........
result = []
for k, v in sorted(fileCountDict2.items(), lambda x, y: cmp(x[1], y[1]), reverse=True) :
result.append(k)
result2 = []
for k, v in fileCountDict3.items():
result2.append(k)
return result2 + result
def genFileList(self, dataList, divID='', rID='', url='', higtLightText=''):
if len(dataList) == 0:
return ''
print 'genFileList ' + ' '.join(dataList)
#print 'higtLightText:' + higtLightText
html = ''
count = 0
log = True
if rID.startswith('loop'):
log = False
if len(dataList) > 0:
html = '<div class="ref"><ol>'
for line in dataList:
if line != '' and (line.find('exclusive') == -1 or line.find('.') != -1):
if url != '' and line.strip().replace(' ', '%20') == url.strip():
continue
if line.endswith('.DS_Store'):
continue
count += 1
html += '<li><span>' + str(count) + '.</span>'
url = line
title = line[line.rfind('/') + 1 :].replace("'", ' ').replace('"', '')
openAllHtml = ''
if self.isDir(line):
icon = self.utils.getIconHtml('quickaccess')
js = ''
fileCount = 0
for f in self.getMatchFiles('', url=url).split('\n'):
if f != '' and os.path.exists(f):
fileCount += 1
js += "exec('open','','" + f + "');"
if fileCount > 0:
openAllHtml = ' <font size="1">(</font><font size="1" color="#999966">' + str(fileCount) + '</font><font size="1">)</font> <a target="_blank" href="javascript:void(0);" onclick="' + js + '">' + icon + '</a>'
if line.startswith('db/') and (line[0 : len(line) - 1].endswith(str(datetime.date.today().year)[0 : 3]) or line.find('(') != -1):
countInfo = ''
if line.find('(') != -1:
countInfo = '(<font color="red"><b>' + line[line.find('(') + 1 : line.find(')')] + '</b></font>)'
line = line[0 : line.find('(')]
title = title[0 : title.rfind('(')].strip()
if title.find('-library') != -1:
title = '<font color="red">' + title + '</font>'
url = 'http://' + Config.ip_adress + '/?db=' + line[line.find('/') + 1 : line.rfind('/') + 1] + '&key=' + line[line.rfind('/') + 1 :]
if line.find('paper') != -1:
url += '&column=1'
else:
url += '&column=' + Config.column_num + '&width=' + Config.default_width
if self.dbFileArgsDict.has_key(line.strip()):
url += '&filter=' + self.dbFileArgsDict[line.strip()]
showText = title + countInfo
if higtLightText != '':
showText = self.utils.doHighLight(title, higtLightText, appendValue=False) + countInfo
#print showText
html += '<p>' + self.utils.enhancedLink(url, title, module='filefinder', rid=self.form_dict['rID'], library=self.form_dict['originFileName'], showText=showText, log=log) + openAllHtml
else:
showText = title
if higtLightText != '':
showText = self.utils.doHighLight(title, higtLightText, appendValue=False)
#print showText
html += '<p>' + self.utils.enhancedLink(line, title, module='filefinder', rid=self.form_dict['rID'], library=self.form_dict['originFileName'], showText=showText, log=log) + openAllHtml + self.utils.getIconHtml(line)
#print js
if divID != '':
divID += '-' + str(count)
linkID = 'a-' + divID[divID.find('-') + 1 :]
appendID = str(count)
url = url.replace(' ', '#space')
script = self.utils.genMoreEnginScript(linkID, divID, "loop-f-" + rID.replace(' ', '-') + '-' + str(appendID) , title, url, '-', hidenEnginSection=Config.bookmark_hiden_engin_section)
html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', divID, '', False);
html += '</p></li>'
html += "</ol></div>"
if count == 0:
html = ''
return html
def check(self, form_dict):
return True
示例9: Reference
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import genMoreEnginScript [as 别名]
#.........这里部分代码省略.........
else:
continue
elif a['href'].startswith('/playlist'):
link = 'http://www.youtube.com' + a['href']
else:
link = a['href']
print a['href']
if self.passItem(a.text.strip(), link):
continue
title = a.text.strip().encode('utf-8')
if title == '':
title = link.replace('http://', '').replace('www.', '')
link_dict[link] = link
link = self.utils.fixUrl(url, link)
text = title
if url.find('youtube') != -1 and link.find('watch') != -1:
link = 'https://www.youtube.com' + link[link.rfind('/watch') :]
if url.find('playlist') == -1:
if a.text.find('Duration') != -1:
text = self.formatYoutubeLink(a, True).replace(' ', '%20')
title = self.formatYoutubeLink(a, False)
else:
text = self.utils.removeDoubleSpace(a.text.strip()).replace(' ', '%20')
if title.startswith('/watch'):
continue
elif url.endswith('playlist') == False:
if count == 0:
return self.getAllLinks(link, ref_divID, rID)
count += 1
print str(count) + ' ' + title + ' ' + link
ref_divID += '-' + str(count)
linkID = 'a-' + ref_divID[ref_divID.find('-') + 1 :]
appendID = str(count)
script = self.utils.genMoreEnginScript(linkID, ref_divID, "loop-" + rID.replace(' ', '-') + '-' + str(appendID), text, link, '-', hidenEnginSection=Config.reference_hiden_engin_section)
#if a.img != None and a.img['src'].endswith('gif') == False:
# html += '<img width="48" height="48" src="' + a.img['src'] + '">'
html += '<li><span>' + str(count) + '.</span>'
if title.find('- Duration') != -1:
html += '<p>' + self.utils.enhancedLink(link, self.utils.formatTitle(title[0 : title.find('- Duration')], Config.reference_smart_link_br_len), module='reference') + title[title.find('- Duration') :]
records.append(self.toRecord('reference-' + str(count), title[0 : title.find('- Duration')], link))
else:
html += '<p>' + self.utils.enhancedLink(link, self.utils.formatTitle(title, Config.reference_smart_link_br_len), module='reference')
records.append(self.toRecord('reference-' + str(count), title, link))
if script != "":
html += self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', ref_divID, '', False);
html += '</p></li>'
html += '</ol></div>'
if count == 0:
html = ''
if Config.reference_output_data_to_new_tab:
return self.utils.output2Disk(records, 'reference', self.form_dict['rTitle'], Config.reference_output_data_format)
else:
return html
def toRecord(self, rid, title, url):
return Record(rid + ' | ' + title.replace('\n', '') + ' | ' + url + ' | ')
def isYoutubeRssUrl(self, url):
return (url.find('user') != -1 or url.find('channel') != -1) and (url.find('playlists') != -1 or url.find('videos') != -1) and url.find('watch') == -1 and url.find('youtube') != -1
def youtubeRssHtml(self, url, rid, divid):
if url.find('playlist') != -1:
return self.genRssHtml(self.helper.getPlaylists(url), rid, divid)
elif url.find('video') != -1:
示例10: Content
# 需要导入模块: from utils import Utils [as 别名]
# 或者: from utils.Utils import genMoreEnginScript [as 别名]
#.........这里部分代码省略.........
if contentref != None:
return contentref.strip()
return ''
def write(self, html):
f = open('temp/test.html', 'w')
for line in html:
f.write(line)
#print 'write ' + html + ' to file'
f.close
def genContentHtml(self, key, content_divID, defaultLinks, library):
return self.genMetadataHtml(key, content_divID, defaultLinks, library)
def genMetadataHtml(self, key, content_divID, defaultLinks, library):
html = '<div class="ref"><ol>'
if self.form_dict['column'] == '3' and int(self.form_dict['extension_count']) > 10:
html = '<div class="ref"><br><ol>'
count = 0
#print 'key:' + key
#print self.datafile_content
if self.datafile_content.has_key(key):
self.record_content = self.datafile_content
elif self.optional_content.has_key(key):
self.record_content = self.optional_content
if self.record_content.has_key(key):
#print key
for r in self.record_content[key]:
count += 1
format_index = ''
pRecord = None
pid = r.get_parentid().strip()
if self.record_content.has_key(pid) and key.find('-') != -1:
pRecord = self.record_content[pid]
if content_divID.find(self.data_type) == content_divID.rfind(self.data_type):
format_index = str(count)
else:
format_index = pid[pid.rfind('-') + 1 :] + '.' + str(count)
elif r.get_id().find('-') != -1:
format_index = r.get_id()[r.get_id().rfind('-') + 1 : ].strip()
while format_index.find('-') != -1:
format_index = format_index[format_index.find('-') + 1 :]
html += '<li><span>' + format_index + '</span>'
if len(format_index) > 5:
html += '</li><br/><li>'
content_divID += '-' + str(count)
linkID = 'a-' + content_divID[content_divID.find('-') + 1 :]
title = r.get_title().strip().replace(' ', '%20')
desc = r.get_describe().strip()
script = self.utils.genMoreEnginScript(linkID, content_divID, r.get_id().strip(), self.utils.clearHtmlTag(title), r.get_url().strip(), '-', hidenEnginSection=Config.content_hiden_engin_section)
descHtml = ''
if desc != '':
descHtml = self.utils.genDescHtml(desc, Config.course_name_len, self.tag.tag_list, iconKeyword=True, fontScala=1, module='history')
moreHtml = self.utils.genMoreEnginHtml(linkID, script.replace("'", '"'), '...', content_divID, '', False, descHtml=descHtml);
if self.record_content.has_key(r.get_id().strip()) or r.get_url().strip() == '':
if r.get_url().strip() != '':
html += '<p>' + self.genMetadataLink(r.get_title().strip(), r.get_url().strip())
else:
html += '<p>' + self.utils.toSmartLink(r.get_title().strip(), 45, module='content', rid=self.form_dict['rID'], library=library)
#html += self.utils.getDefaultEnginHtml(title, defaultLinks)
if moreHtml != "":
html += moreHtml
html += '</p>'
elif r.get_url().strip() != '':
html += '<p>' + self.genMetadataLink(r.get_title().strip(), r.get_url().strip()) + moreHtml + '</p>'
html += '</li>'
else:
return ''
html += "</ol></div>"
return html
def genMetadataLink(self, title, url):
if url.find('[') != -1:
ft = url.replace('[', '').replace(']', '').strip()
r = self.utils.getRecord(ft, '','', False, False)
key = r.get_path()[r.get_path().find(default_subject) + len(default_subject) + 1 :]
url = 'http://' + Config.ip_adress + '?db=' + default_subject + '/&key=' + key + '&filter=' + ft + '&desc=true'
return self.genMetadataLinkEx(title, url)
def genMetadataLinkEx(self, title, url):
if title.find('<a>') != -1:
title = title.replace('<a>', '<a target="_blank" href="' + url + '">')
else:
title = self.utils.enhancedLink(url, self.utils.formatTitle(title, 45), module='content', rid=self.form_dict['rID'], library=self.form_dict['originFileName'])
return title