Created
November 20, 2013 18:02
-
-
Save ckorn/7567951 to your computer and use it in GitHub Desktop.
Shows all videos in a YouTube playlist and downloads them using xVideoServiceThief.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # http://proxer.me/watch?a=214&l=engsub&e=8#top | |
| # repository.py | |
| import wx | |
| import sys | |
| from wx.lib.mixins.listctrl import CheckListCtrlMixin, ListCtrlAutoWidthMixin | |
| import gdata.youtube | |
| import gdata.youtube.service | |
| import time | |
| import os | |
| yt_service = gdata.youtube.service.YouTubeService() | |
| yt_service.developer_key = '' | |
| class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin, ListCtrlAutoWidthMixin): | |
| def __init__(self, parent): | |
| wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT | wx.SUNKEN_BORDER) | |
| CheckListCtrlMixin.__init__(self) | |
| ListCtrlAutoWidthMixin.__init__(self) | |
| class Repository(wx.Frame): | |
| def __init__(self, parent, id, title): | |
| wx.Frame.__init__(self, parent, id, title, size=(850, 400)) | |
| panel = wx.Panel(self, -1) | |
| vbox = wx.BoxSizer(wx.VERTICAL) | |
| hbox = wx.BoxSizer(wx.HORIZONTAL) | |
| leftPanel = wx.Panel(panel, -1) | |
| rightPanel = wx.Panel(panel, -1) | |
| self.tc = wx.TextCtrl(rightPanel) | |
| self.tc.SetValue("PLsbE5r1F_cSKRzGz_ihf7h_DZwDnBq7nO") | |
| self.log = wx.TextCtrl(rightPanel, -1, style=wx.TE_MULTILINE) | |
| self.list = CheckListCtrl(rightPanel) | |
| self.list.InsertColumn(0, '#', width=60) | |
| self.list.InsertColumn(1, 'Title', width=400) | |
| self.list.InsertColumn(2, 'Link', width=300) | |
| vbox2 = wx.BoxSizer(wx.VERTICAL) | |
| rpl = wx.Button(leftPanel, -1, 'Read Playlist', size=(100, -1)) | |
| sel = wx.Button(leftPanel, -1, 'Select All', size=(100, -1)) | |
| des = wx.Button(leftPanel, -1, 'Deselect All', size=(100, -1)) | |
| apply = wx.Button(leftPanel, -1, 'Apply', size=(100, -1)) | |
| self.Bind(wx.EVT_BUTTON, self.OnReadPlaylist, id=rpl.GetId()) | |
| self.Bind(wx.EVT_BUTTON, self.OnSelectAll, id=sel.GetId()) | |
| self.Bind(wx.EVT_BUTTON, self.OnDeselectAll, id=des.GetId()) | |
| self.Bind(wx.EVT_BUTTON, self.OnApply, id=apply.GetId()) | |
| vbox2.Add(rpl) | |
| vbox2.Add(sel, 0, wx.TOP, 5) | |
| vbox2.Add(des) | |
| vbox2.Add(apply) | |
| leftPanel.SetSizer(vbox2) | |
| vbox.Add(self.tc, 0, wx.EXPAND) | |
| vbox.Add(self.list, 1, wx.EXPAND | wx.TOP, 3) | |
| vbox.Add((-1, 10)) | |
| vbox.Add(self.log, 1, wx.EXPAND) | |
| vbox.Add((-1, 10)) | |
| rightPanel.SetSizer(vbox) | |
| hbox.Add(leftPanel, 0, wx.EXPAND | wx.RIGHT, 5) | |
| hbox.Add(rightPanel, 1, wx.EXPAND) | |
| hbox.Add((3, -1)) | |
| panel.SetSizer(hbox) | |
| self.Centre() | |
| self.Show(True) | |
| def OnReadPlaylist(self, event): | |
| self.list.DeleteAllItems() | |
| playlistID = self.tc.GetValue() | |
| if playlistID[:2] == "PL": | |
| playlistID = playlistID[2:] | |
| # a typical playlist URI | |
| playlist_uri = 'http://gdata.youtube.com/feeds/api/playlists/' + playlistID | |
| playlist_video_feed = yt_service.GetYouTubePlaylistVideoFeed(uri=playlist_uri) | |
| self.SetTitle(playlist_video_feed.title.text) | |
| self.log.SetValue(playlist_video_feed.subtitle.text or "") | |
| links = [] | |
| i = 1 | |
| while True: | |
| for playlist_video_entry in playlist_video_feed.entry: | |
| #pprint.pprint(inspect.getmembers(playlist_video_entry)) | |
| index = self.list.InsertStringItem(sys.maxint, str(i)) | |
| self.list.SetStringItem(index, 1, playlist_video_entry.title.text) | |
| self.list.SetStringItem(index, 2, playlist_video_entry.GetHtmlLink().href) | |
| i = i + 1 | |
| nextLink = playlist_video_feed.GetNextLink() | |
| if not nextLink: break | |
| playlist_video_feed = yt_service.GetYouTubePlaylistVideoFeed(uri=nextLink.href) | |
| def OnSelectAll(self, event): | |
| num = self.list.GetItemCount() | |
| for i in range(num): | |
| self.list.CheckItem(i) | |
| def OnDeselectAll(self, event): | |
| num = self.list.GetItemCount() | |
| for i in range(num): | |
| self.list.CheckItem(i, False) | |
| def OnApply(self, event): | |
| num = self.list.GetItemCount() | |
| for i in range(num): | |
| if self.list.IsChecked(i): | |
| time.sleep(0.500) | |
| os.popen("xvst " + self.list.GetItem(i, 2).GetText()) | |
| app = wx.App() | |
| Repository(None, -1, 'Repository') | |
| app.MainLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment