Advertisement
Heretiiik

Untitled

Sep 11th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.17 KB | None | 0 0
  1. #! /usr/bin/python3
  2.  
  3. from __future__ import unicode_literals
  4. import youtube_dl
  5. import pprint
  6.  
  7. class MyLogger(object):
  8.     def debug(self, msg):
  9.         pass
  10.  
  11.     def warning(self, msg):
  12.         pass
  13.  
  14.     def error(self, msg):
  15.         print(msg)
  16.  
  17.  
  18.  
  19. ydl_opts = {'logger': MyLogger(),}
  20. with youtube_dl.YoutubeDL(ydl_opts) as ydl:
  21.     result = ydl.extract_info('https://www.youtube.com/watch?v=uD96pR-fqeM', download = False)
  22.    
  23.  
  24. #pprint.pprint (result)
  25. print (result["thumbnail"])
  26. print (result["title"])
  27. filtered = []
  28. for f in result["formats"]:
  29.     if f["acodec"] != "none" and 'abr' in f:
  30.         filtered.append(f)
  31.         #print (f["format"], f["acodec"], f["abr"], f["ext"])
  32. #pprint.pprint (filtered)
  33. for f in filtered:
  34.     print (f["format"], f["acodec"], f["abr"], f["ext"])
  35. #!/usr/bin/python3
  36. """
  37. Hello World, but with more meat.
  38. """
  39.  
  40. import wx
  41.  
  42. class MainFrame(wx.Frame):
  43.     """
  44.    A Frame that says Hello World
  45.    """
  46.  
  47.     def __init__(self, *args, **kw):
  48.         # ensure the parent's __init__ is called
  49.         super(MainFrame, self).__init__(*args, **kw)
  50.  
  51.         # create a panel in the frame
  52.         pnl = wx.Panel(self)
  53.  
  54.         # create input line
  55.         url_label = wx.StaticText(pnl, label="URL:", pos=(10,8))
  56.         url = wx.TextCtrl(pnl, pos=(45,3), size=(495,-1))
  57.         url_submit = wx.Button(pnl, label="Load", pos=(550,0))
  58.         url_submit.Bind(wx.EVT_BUTTON, self.OnGetVideoInfo)
  59.         # create a menu bar
  60.         self.makeMenuBar()
  61.  
  62.         # and a status bar
  63.         self.CreateStatusBar()
  64.         self.SetStatusText("Idle!")
  65.  
  66.         # move to the center of screen
  67.         self.Centre()
  68.  
  69.     def makeMenuBar(self):
  70.         """
  71.        A menu bar is composed of menus, which are composed of menu items.
  72.        This method builds a set of menus and binds handlers to be called
  73.        when the menu item is selected.
  74.        """
  75.        
  76.         # Make a file menu with Hello and Exit items
  77.         fileMenu = wx.Menu()
  78.         # The "\t..." syntax defines an accelerator key that also triggers
  79.         # the same event
  80.         helloItem = fileMenu.Append(-1, "&Hello...\tCtrl-H",
  81.                 "Help string shown in status bar for this menu item")
  82.         fileMenu.AppendSeparator()
  83.         # When using a stock ID we don't need to specify the menu item's
  84.         # label
  85.         exitItem = fileMenu.Append(wx.ID_EXIT)
  86.  
  87.         # Now a help menu for the about item
  88.         helpMenu = wx.Menu()
  89.         aboutItem = helpMenu.Append(wx.ID_ABOUT)
  90.  
  91.         # Make the menu bar and add the two menus to it. The '&' defines
  92.         # that the next letter is the "mnemonic" for the menu item. On the
  93.         # platforms that support it those letters are underlined and can be
  94.         # triggered from the keyboard.
  95.         menuBar = wx.MenuBar()
  96.         menuBar.Append(fileMenu, "&File")
  97.         menuBar.Append(helpMenu, "&Help")
  98.  
  99.         # Give the menu bar to the frame
  100.         self.SetMenuBar(menuBar)
  101.  
  102.         # Finally, associate a handler function with the EVT_MENU event for
  103.         # each of the menu items. That means that when that menu item is
  104.         # activated then the associated handler function will be called.
  105.         self.Bind(wx.EVT_MENU, self.OnHello, helloItem)
  106.         self.Bind(wx.EVT_MENU, self.OnExit,  exitItem)
  107.         self.Bind(wx.EVT_MENU, self.OnAbout, aboutItem)
  108.  
  109.  
  110.     def OnExit(self, event):
  111.         """Close the frame, terminating the application."""
  112.         self.Close(True)
  113.  
  114.  
  115.     def OnHello(self, event):
  116.         """Say hello to the user."""
  117.         wx.MessageBox("Hello again from wxPython")
  118.  
  119.  
  120.     def OnAbout(self, event):
  121.         """Display an About Dialog"""
  122.         wx.MessageBox("This is a wxPython Hello World sample",
  123.                       "About Hello World 2",
  124.                       wx.OK|wx.ICON_INFORMATION)
  125.  
  126.     def OnGetVideoInfo(self, event):
  127.         wx.MessageBox("Placeholder")
  128.  
  129. if __name__ == '__main__':
  130.     # When this module is run (not imported) then create the app, the
  131.     # frame, show it, and start the event loop.
  132.     app = wx.App()
  133.     frm = MainFrame(None, title='Youtube Donloader',size=(640, 480))
  134.     frm.Show()
  135.     app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement