scandisk.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import os
  2. import sys
  3. import dataset
  4. import codecs
  5. fname_dict={}
  6. fulllst=['#31','#32','#33','#34','#35','#36','#37','#38','#39','#40','#41','#42']
  7. fr=codecs.open('c:/tmp/ytfiles.csv','r','utf-8')
  8. lines=fr.readlines()
  9. fr.close()
  10. ## .mp4 -> yid
  11. fname_yiddict={}
  12. for l in lines:
  13. elmts=l.split(',')
  14. if len(elmts[2])>10:
  15. fname_yiddict[elmts[0].lower().replace('\r','').replace('\n','')]=elmts[2].replace('\r','').replace('\n','').replace("http://youtu.be/",'').replace("https://youtu.be/",'')
  16. for lst_elmt in fulllst:
  17. lst=os.listdir('P:\\【完整版】幸福空間節目\\'+lst_elmt)
  18. for l in lst:
  19. fname_dict[l]='P:\\【完整版】幸福空間節目\\'+lst_elmt+"\\"+l
  20. print(l)
  21. print('P:\\【完整版】幸福空間節目\\'+lst_elmt+"\\"+l)
  22. db2 = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
  23. table=db2['yt_tasks']
  24. db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@127.0.0.1:13317/xoops?charset=utf8mb4')
  25. # yid -> detail
  26. yiddict={}
  27. cursor=db.query('select youtube_video_id,title,description from youtube_list')
  28. title=None
  29. desc=None
  30. for c in cursor:
  31. # print(c['youtube_video_id'])
  32. yiddict[c['youtube_video_id']]=c
  33. # title=c['title']
  34. # desc=c['description']
  35. for k,v in fname_yiddict.items():
  36. # print(k)
  37. # print(v)
  38. if yiddict.get(v):
  39. if fname_dict.get(k):
  40. table.insert({'fname':k,'path':fname_dict[k],'yid':yiddict[v]['youtube_video_id'],'title':yiddict[v]['title'],'desc':yiddict[v]['description']})
  41. print(k)
  42. print(fname_dict[k])
  43. print(yiddict[v]['youtube_video_id'])
  44. print(yiddict[v]['title'])
  45. #print(lst)