def find(self, text): u""" text からmyformatを返す. text からマイリスが見つかった場合は Mylist_Search.MylistSearch.main() を使用 text からYouTube動画URLが見つかった場合はYouTubeSearch.YouTubeSearch.main() を使用 return -1 はメール削除後continue return 動画URL: movie format mylist : mylist format YouTube: other : False """ nicodl_various = Various.nicoDL_Various() #print '--- find() -----------------------------' #print text matched = re.search('[sn][mo]\d+', text) # videoID検索 #print 'find() matched videoID: %s' % matched ### if matched: video_id = matched.group() print 'Hit!: %s' % video_id ### myformat = nicodl_various.make_myformat(movie_id=video_id, state=False) # movie format #print '--- /find() ----------------------------' #print ## return myformat matched = re.search('mylist/\d+', text) # mylistID検索 #print 'find() matched mylistID: %s' % matched ### if matched: mylist_id = matched.group().strip('mylist/') print 'Hit! mylistID: %s' % mylist_id ### myformat = nicodl_various.make_myformat(mylist_id=mylist_id) # mylist format #print 'Waiting...' time.sleep(0.1) #print '--- /find() ----------------------------' #print ## return myformat """ YOU TUBE matched = re.search('v=\w+', text) # YouTube検索 #youtube.com/watch? #print 'find() matched youtube_videoID: %s' % matched if matched: youtube_video_id = matched.group().strip('v=') print 'Hit! mylistID: %s' % youtube_video_id ### youtubesearch = youtube_search.YouTubeSearch(self.debug) youtubesearch.main(youtube_video_id) #print '--- /find() ----------------------------' print return 3 """ #print '--- /find() ----------------------------' #print ## return False
def OnGetURL(self, evt): """受け取った値をlibraryに書き込む""" nico = RemoteNicovideoDL(None) myformat = nico.find(self.url) #print myformat if myformat: vari = various.nicoDL_Various() vari.write_library(myformat, os.path.join(os.getcwd(), "data")) else: pass self.url = "" self.url_tc.SetValue("")
def find(self, text): u""" textからmyformatを返す textからマイリスが見つかった時はMylist_Search.MylistSearch.main() return 動画URL: movie format mylist : mylist format YouTube: other : False """ nicodl_various = Various.nicoDL_Various() #print '--- find() -----------------------------' #print text matched = re.search('[s][mo]\d+', text) # videoID検索 #print 'find() matched videoID: %s' % matched ### if matched: video_id = matched.group() print 'Hit!: %s' % video_id ### myformat = nicodl_various.make_myformat(movie_id=video_id, state=False, form='MOVIE') # movie format #print '--- /find() ----------------------------' #print ## print self, 'myformat:', myformat return myformat matched = re.search('mylist/\d+', text) # mylistID検索 #print 'find() matched mylistID: %s' % matched ### if matched: mylist_id = matched.group().strip('mylist/') print 'Hit! mylistID: %s' % mylist_id ### myformat = nicodl_various.make_myformat(mylist_id=mylist_id, form='MYLIST') # mylist format #print 'Waiting...' time.sleep(0.1) #print '--- /find() ----------------------------' #print ## return myformat #print '--- /find() ----------------------------' #print ## return False
def run(self): u""" flag: DLするか """ sendmail = SendMail.nicodl_sendmail(self.gid, self.gpw, self.toaddr) # 完了メール送信用 various = Various.nicoDL_Various() message = u'' # メール本文 """start while loop """ while True: myformat = self.geturl() # Gmailチェック #print "myformat:", myformat if myformat == False: # Gamilが空 pass else: # library_ALL.ndl に追加 various.write_library(myformat, os.path.join(self.cdir, "data")) # various.UPDATE() 後で実装 """ if self.checkdir(): pass else: # 空き容量不足でループをリセット print u"空き容量不足:\n %s" % self.savedir time.sleep(300) continue print self.savedir, u"に保存" """ # ライブラリファイルリフレッシュ various.reflesh_libraryfile(os.path.join(self.cdir, "data", "library_ALL.ndl")) # RSS various.rsscheck(os.path.join(self.cdir, "data")) # DL部分 f = open(os.path.join(self.cdir, "data", "library_ALL.ndl")) lib = pickle.load(f) f.close() #print lib for item in lib: #print item #print "for" #"state:",item["state"] if item == None: continue elif item["format"] == "MYLIST": continue elif (item["format"] == "MOVIE") and (item["state"]==False): evt = DownloadEvent(EVT_TYPE_DL, wx.ID_ANY) wx.PostEvent(self.parent, evt) self.display_download = True if item["mylist_id"] != None: mylistflag = item["mylist_name"] else: mylistflag = None nico = Nicovideo.Nicovideo(movie_id=item["movie_id"]) # display self.movie_id_display = item["movie_id"] # wx.PostEvent(self.parent, evt) #self.options_display = item["options"] # # 情報取得 title = self.title_display = nico.get_movie_title() # wx.PostEvent(self.parent, evt) length = nico.get_movie_length() description = self.description_display = nico.get_movie_description() # wx.PostEvent(self.parent, evt) print "".join(["[",item["movie_id"], "]",title, length]) minute = int(length.split(':')[0]) second = int(length.split(':')[1]) now = datetime.datetime.now() end = now + datetime.timedelta(minutes=minute, seconds=second) end = end.strftime('%m/%d %H:%M') print "".join(["[",item["movie_id"], "]",end, u"頃終了します."]) # DL print "".join(["[",item["movie_id"], "]",u" サムネイル取得中..."]) thumbnail = self.thumbnail_display = nico.save_thumbnail(os.path.join(self.cdir, "data\\thumbnail")) wx.PostEvent(self.parent, evt) print "".join(["[",item["movie_id"], "]",u" サムネイル取得完了!"]) print "".join(["[",item["movie_id"], "]",u" 動画取得中..."]) movie_path = nico.save_movie(self.nicoid, self.nicopw, self.savedir, mylist=mylistflag) print "".join(["[",item["movie_id"], "]",u" 動画取得完了!", "\n", movie_path]) # 情報書き換え print "".join(["[",item["movie_id"], "]",u" 情報を更新します..."]) various.rewrite_library(key="thumbnail", value=thumbnail, libraryfilepath=os.path.join(self.cdir, "data\\library_ALL.ndl"),movie_id=item["movie_id"]) various.rewrite_library(key="state", value=True, libraryfilepath=os.path.join(self.cdir, "data\\library_ALL.ndl"),movie_id=item["movie_id"]) various.rewrite_library(key="movie_path", value=movie_path, libraryfilepath=os.path.join(self.cdir, "data\\library_ALL.ndl"),movie_id=item["movie_id"]) # マイリスが登録されていたらそのマイリスのDL済みに追加 if item["mylist_id"] != None: f = open(os.path.join(self.cdir, "data", "library_ALL.ndl")) my = pickle.load(f) f.close() for i in my: if i["mylist_id"] == item["mylist_id"]: various.rewrite_library(key="downloaded", value=item["movie_id"], libraryfilepath=os.path.join(self.cdir, "data\\library_ALL.ndl"),mylist_id=item["mylist_id"]) # メール送信 print "".join(["[",item["movie_id"], "]",u" 完了メール送信"]) mail = SendMail.nicodl_sendmail(self.gid, self.gpw, self.toaddr) mail.main(description, item["movie_id"]) # 外部表示用アトリビュートリセット self.movie_id_display = u"動画ID" self.title_display = u"タイトル" self.description_display = u"動画説明" self.options = u"オプション" self.thumbnail_display = False self.display_download = 0 wx.PostEvent(self.parent, evt) #break print "".join([u"待機中..."]) time.sleep(self.wait_time)