py_pansou.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #coding=utf-8
  2. #!/usr/bin/python
  3. import sys
  4. sys.path.append('..')
  5. from base.spider import Spider
  6. class Spider(Spider):
  7. def getDependence(self):
  8. return ['py_ali']
  9. def getName(self):
  10. return "py_pansou"
  11. def init(self,extend):
  12. self.ali = extend[0]
  13. print("============py_pansou============")
  14. pass
  15. def isVideoFormat(self,url):
  16. pass
  17. def manualVideoCheck(self):
  18. pass
  19. def homeContent(self,filter):
  20. result = {}
  21. return result
  22. def homeVideoContent(self):
  23. result = {}
  24. return result
  25. def categoryContent(self,tid,pg,filter,extend):
  26. result = {}
  27. return result
  28. def detailContent(self,array):
  29. tid = array[0]
  30. print(self.getName())
  31. pattern = '(https:\\/\\/www.aliyundrive.com\\/s\\/[^\\\"]+)'
  32. url = self.regStr(tid,pattern)
  33. if len(url) > 0:
  34. return self.ali.detailContent(array)
  35. rsp = self.fetch('https://www.alipansou.com'+tid)
  36. url = self.regStr(rsp.text,pattern)
  37. if len(url) == 0:
  38. return ""
  39. url = url.replace('\\','')
  40. newArray = [url]
  41. print(newArray)
  42. return self.ali.detailContent(newArray)
  43. def searchContent(self,key,quick):
  44. map = {
  45. '7':'文件夹',
  46. '1':'视频'
  47. }
  48. ja = []
  49. for tKey in map.keys():
  50. url = "https://www.alipansou.com/search?k={0}&t={1}".format(key,tKey)
  51. rsp = self.fetch(url)
  52. root = self.html(self.cleanText(rsp.text))
  53. aList = root.xpath("//van-row/a")
  54. for a in aList:
  55. title = ''
  56. # title = a.xpath('string(.//template/div)')
  57. # title = self.cleanText(title).strip()
  58. divList = a.xpath('.//template/div')
  59. for div in divList:
  60. t = div.xpath('string(.)')
  61. t = self.cleanText(t).strip()
  62. title = title + t
  63. if key in title:
  64. pic = 'https://www.alipansou.com'+ self.xpText(a,'.//van-card/@thumb')
  65. jo = {
  66. 'vod_id': a.xpath('@href')[0],
  67. 'vod_name': '[{0}]{1}'.format(key,title),
  68. 'vod_pic': pic
  69. }
  70. ja.append(jo)
  71. result = {
  72. 'list':ja
  73. }
  74. return result
  75. def playerContent(self,flag,id,vipFlags):
  76. return self.ali.playerContent(flag,id,vipFlags)
  77. config = {
  78. "player": {},
  79. "filter": {}
  80. }
  81. header = {}
  82. def localProxy(self,param):
  83. return [200, "video/MP2T", action, ""]