[Tutor] Python Script: Downloading Youtube videos by search result
Dear All, I want to download some music from youtube.There are already marvellous python scripts like youtube-dl which downloads videos and playlists from numerous sites,but what I want to do is to download videos from youtube with a search string. The user will give a search string, and the script will download first 20(say) videos from the youtube.The script will use youtube-dl on the backend and avconv tool for video to MP3 conversion etc. How should I proceed to make such a script. I am a newbie in Python but I am sure with your guidance I can pick it up quite fast. :) Cheers, Sayan -- -- *Sayan Chatterjee* Dept. of Physics and Meteorology IIT Kharagpur Lal Bahadur Shastry Hall of Residence Room AB 205 Mob: +91 9874513565 blog: www.blissprofound.blogspot.com Volunteer , Padakshep www.padakshep.org ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] path directory backslash ending
On Thu, Apr 18, 2013 at 8:51 PM, Jim Mooney wrote: > > But that's in win 7. Is it okay to always omit them in Linux? Python33 > is itself installed with a trailing backslash, so I figured this was a > Linux habit. POSIX/Linux uses a forward slash instead of a backslash (py: os.sep), and the delimiter in PATH is a colon instead of a semicolon (py: os.pathsep). There's no convention I know of to use trailing slashes. You might also consider using the PEP 405 "venv" module: http://www.python.org/dev/peps/pep-0405 When you "activate" the environment it prepends the "Scripts" (or "bin") directory to PATH. The option "--symlinks" requires an elevated security token on Windows, but just to create the virtual environment. If you'd rather copy over the required DLLs, there's a "--upgrade" option for when you upgrade to Python 3.4, etc. > An entirely different question as long as I'm here. I have a local > wamp server with mysql and phpadmin for php so I can test web pages > locally. What's the equivalent for Python? Here's a sampling of links. Hopefully a web developer will provide a more detailed answer. mod_wsgi http://code.google.com/p/modwsgi http://code.google.com/p/modwsgi/wiki/InstallationOnWindows The wiki has several integration guides for popular frameworks. mod_wsgi Windows binaries: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi Python Web Server Gateway Interface v1.0.1 http://www.python.org/dev/peps/pep- ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] hard time importing a module
hi I have a question about modules ... Im trying to use a 3rd party module called pywinatuo. It said I had to install 2 other modules. 1 was called sendkeys.py, the other was ctypes. Ctypes was included in the python library I had, but sendkeys was not. After I found SendKeys, I put it in a directory I found in sys.path, and then type import SendKeys. I got an error because sendkeys was trying to import from another file called _sendkeys. After searching I found _sendkeys, but it is .c I know that you can somehow extend python with c from reading this article : http://docs.python.org/2/extending/extending.html But... how do I get the interpreter to recognize the _sendkeys.c file when sendkeys.py trys to import it ? I get errors right away since c uses * to comment so python doesnt recognize it and errors on all of the comments from _sendkeys.c Basically how do I correctly import this module that doesnt have a setup.py ? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] hard time importing a module
On 19 April 2013 15:49, Frank Schiro wrote: > hi I have a question about modules ... > > Im trying to use a 3rd party module called pywinatuo. It said I had to > install 2 other modules. 1 was called sendkeys.py, the other was ctypes. > Ctypes was included in the python library I had, but sendkeys was not. > > After I found SendKeys, I put it in a directory I found in sys.path, and > then type import SendKeys. I got an error because sendkeys was trying to > import from another file called _sendkeys. After searching I found > _sendkeys, but it is .c Did these files also come with a file called setup.py? Normally, a Python module is not installed by manually copying the files to the appropriate places but by running 'python setup.py install' in the terminal. This will compile any C code and copy files to the appropriate places. Note that you will need to have separately installed a C compiler to be able to compile C code. > > I know that you can somehow extend python with c from reading this article : > http://docs.python.org/2/extending/extending.html Try reading this one instead: http://docs.python.org/2/install/index.html > > But... how do I get the interpreter to recognize the _sendkeys.c file when > sendkeys.py trys to import it ? I get errors right away since c uses * to > comment so python doesnt recognize it and errors on all of the comments from > _sendkeys.c Yeah, that won't work. C code needs to be compiled by a C compiler, not Python. > > Basically how do I correctly import this module that doesnt have a setup.py > ? Oh okay, no setup.py. Where did you get this from? What does it have? Is there a Makefile or something? Oscar ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] hard time importing a module
On Fri, Apr 19, 2013 at 11:12 AM, Oscar Benjamin wrote: > Did these files also come with a file called setup.py? > > Normally, a Python module is not installed by manually copying the > files to the appropriate places but by running 'python setup.py > install' in the terminal. This will compile any C code and copy files > to the appropriate places. Note that you will need to have separately > installed a C compiler to be able to compile C code. I think this is the SendKeys module in question: http://web.archive.org/web/20121002234104/http://www.rutherfurd.net/python/sendkeys You can get the zipped source from archive.org above, along with binaries for 2.1-2.6. The source has a setup.py, but as Oscar said already you'll need a C compiler. You can use Visual Studio 2008 to compile it for 2.6/2.7. There are direct links for VS 2008 Express edition (free as in beer) in this SO answer: http://stackoverflow.com/a/14979612/205580 Or use MinGW-w64 if you prefer since the source isn't C++: http://mingw-w64.sourceforge.net/ There's also a binary installer for 2.7 here, courtesy of Christoph Gohlke: http://www.lfd.uci.edu/~gohlke/pythonlibs/#sendkeys ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] hard time importing a module
On 19/04/2013 16:39, eryksun wrote: > On Fri, Apr 19, 2013 at 11:12 AM, Oscar Benjamin > wrote: >> Did these files also come with a file called setup.py? >> >> Normally, a Python module is not installed by manually copying the >> files to the appropriate places but by running 'python setup.py >> install' in the terminal. This will compile any C code and copy files >> to the appropriate places. Note that you will need to have separately >> installed a C compiler to be able to compile C code. > > I think this is the SendKeys module in question: > > http://web.archive.org/web/20121002234104/http://www.rutherfurd.net/python/sendkeys > > You can get the zipped source from archive.org above, along with > binaries for 2.1-2.6. The source has a setup.py, but as Oscar said > already you'll need a C compiler. You can use Visual Studio 2008 to > compile it for 2.6/2.7. There are direct links for VS 2008 Express > edition (free as in beer) in this SO answer: As usual, the excellent Christoph Gohlke has provided binaries for a range of targets: http://www.lfd.uci.edu/~gohlke/pythonlibs/ TJG ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] hard time importing a module
On 19/04/2013 16:39, eryksun wrote: On Fri, Apr 19, 2013 at 11:12 AM, Oscar Benjamin wrote: Did these files also come with a file called setup.py? Normally, a Python module is not installed by manually copying the files to the appropriate places but by running 'python setup.py install' in the terminal. This will compile any C code and copy files to the appropriate places. Note that you will need to have separately installed a C compiler to be able to compile C code. I think this is the SendKeys module in question: http://web.archive.org/web/20121002234104/http://www.rutherfurd.net/python/sendkeys You can get the zipped source from archive.org above, along with binaries for 2.1-2.6. The source has a setup.py, but as Oscar said already you'll need a C compiler. You can use Visual Studio 2008 to compile it for 2.6/2.7. There are direct links for VS 2008 Express edition (free as in beer) in this SO answer: http://stackoverflow.com/a/14979612/205580 Or use MinGW-w64 if you prefer since the source isn't C++: http://mingw-w64.sourceforge.net/ There's also a binary installer for 2.7 here, courtesy of Christoph Gohlke: http://www.lfd.uci.edu/~gohlke/pythonlibs/#sendkeys ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor At least two variants on sendkeys are here on stackoverflow if none of the above work out http://tinyurl.com/cuwdhjk -- If you're using GoogleCrap™ please read this http://wiki.python.org/moin/GoogleGroupsPython. Mark Lawrence ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] hard time importing a module
On Fri, Apr 19, 2013 at 11:52 AM, Tim Golden wrote: > As usual, the excellent Christoph Gohlke has provided binaries for a > range of targets: > > http://www.lfd.uci.edu/~gohlke/pythonlibs/ Maybe you missed the link at the end of my link fest: http://www.lfd.uci.edu/~gohlke/pythonlibs/#sendkeys ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] hard time importing a module
On 19/04/2013 17:12, eryksun wrote: > On Fri, Apr 19, 2013 at 11:52 AM, Tim Golden wrote: >> As usual, the excellent Christoph Gohlke has provided binaries for a >> range of targets: >> >> http://www.lfd.uci.edu/~gohlke/pythonlibs/ > > Maybe you missed the link at the end of my link fest: > > http://www.lfd.uci.edu/~gohlke/pythonlibs/#sendkeys > Whoops. Quite right. Still, better twice than not at all ;) TJG ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Hello, and a newbie question
eryksun wrote: > On Tue, Apr 16, 2013 at 7:57 PM, Virgilio Rodriguez Jr > wrote: > > Can someone please do me the favor and remove me from this god forsaken > > email list I am sorry I signed up all it has done is taken over my phone and > > rings all night long with emails I am not interested in any more because it > > is just too many darn emails. I keep trying to log in and nothing it will > > not let me unsubscribe and it is BS already. > > You can get a password reminder here: > http://mail.python.org/mailman/options/tutor > > If you're sure that you have the correct password and still can't > unsubscribe, then email the administrator, tutor-ow...@python.org. > Alan Gauld is active in this thread, BTW, in case you happen to have > read the admin page where it says "Tutor list run by wescpy at > gmail.com, alan.gauld at btinternet.com". Or switch to digest mode which will email once a day with all the messages in it. Be glad you are not subscribed to the main Python mailing list as it is far more active than the tutor list. ;) ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] How to find reverse pair words in a list of Words that has to be accessed through a URL
*Here is my question:* * * *"Two words are a “reverse pair” if each is the reverse of the other. Write a program that finds all the reverse pairs in the word list. The word list can be downloaded athttp://www.puzzlers.org/pub/wordlists/pocket.txt"* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to find reverse pair words in a list of Words that has to be accessed through a URL
On Apr 19, 2013, at 4:56 PM, Chetan Sai wrote: > Here is my question: > > "Two words are a “reverse pair” if each is the reverse of the other. Write a > program that finds all the reverse pairs in the word list. The word list can > be downloaded athttp://www.puzzlers.org/pub/wordlists/pocket.txt"; Really, that's not a question, but we are happy to answer questions :>) Oh, there's your question in the subject line. What have you tried thus far? Have you given any thought to what steps you might have to take to solve this task? Take care, Don ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to find reverse pair words in a list of Words that has to be accessed through a URL
Hi Don I'm a beginner in Python Programming. I'm using python 3. I wrote a program that checks whether given two words are reverse pair or not and outputs TRUE/FALSE. *def reverse_pair(a,b):* *return list(a)==list(reversed(list(b)))* * * * * But how to write a program that finds all the reverse pairs in the given word list, eg: how to find the reverse pair words in a list of 20 words. And that to how to access those list of words form a URL. Because with the above code we can only find out whether the given 2 words are reverse pair or not, that's it. I'm thinking of using the below code which is written for Python 2.7. Code: def reverse_pair(word_list, word): """Checks whether a reversed word appears in word_list. word_list: list of strings word: string """ rev_word = word[::-1] return in_bisect(word_list, rev_word) if __name__ == '__main__': word_list = make_word_list() for word in word_list: if reverse_pair(word_list, word): print word, word[::-1] On Fri, Apr 19, 2013 at 2:05 PM, Don Jennings wrote: > > On Apr 19, 2013, at 4:56 PM, Chetan Sai wrote: > > > Here is my question: > > > > "Two words are a “reverse pair” if each is the reverse of the other. > Write a program that finds all the reverse pairs in the word list. The word > list can be downloaded athttp://www.puzzlers.org/pub/wordlists/pocket.txt"; > > Really, that's not a question, but we are happy to answer questions :>) > Oh, there's your question in the subject line. What have you tried thus > far? Have you given any thought to what steps you might have to take to > solve this task? > > Take care, > Don > > -- Thanks & Regards Sai Chetan Pothula 408-203-3323 On Fri, Apr 19, 2013 at 2:05 PM, Don Jennings wrote: > > On Apr 19, 2013, at 4:56 PM, Chetan Sai wrote: > > > Here is my question: > > > > "Two words are a “reverse pair” if each is the reverse of the other. > Write a program that finds all the reverse pairs in the word list. The word > list can be downloaded athttp://www.puzzlers.org/pub/wordlists/pocket.txt"; > > Really, that's not a question, but we are happy to answer questions :>) > Oh, there's your question in the subject line. What have you tried thus > far? Have you given any thought to what steps you might have to take to > solve this task? > > Take care, > Don > > -- Thanks & Regards Sai Chetan Pothula 408-203-3323 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to find reverse pair words in a list of Words that has to be accessed through a URL
On 19/04/13 22:19, Chetan Sai wrote: I'm a beginner in Python Programming. The language isn't really the issue here the issue is the algorithm. So how would you do it manually with a paper and pen? (forget about fetching the list from the URL for now) One possibility is to use sets (Python has a set data type). create a set of words. Now create a set of reversed words. The intersection of those sets is the set of words which also have a reversed pair. print the intersection set. just one way. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to find reverse pair words in a list of Words that has to be accessed through a URL
On 04/19/2013 03:07 PM, Alan Gauld wrote: On 19/04/13 22:19, Chetan Sai wrote: I'm a beginner in Python Programming. The language isn't really the issue here the issue is the algorithm. So how would you do it manually with a paper and pen? (forget about fetching the list from the URL for now) One possibility is to use sets (Python has a set data type). create a set of words. Now create a set of reversed words. The intersection of those sets is the set of words which also have a reversed pair. print the intersection set. The gotcha with this approach is the border case of self paired words that aren't pairs. (pop,wow,mom,etc) I got 94 distinct pairs. Which is a better result than the 124.5 pairs I got the first pass through. Emile ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Python Script: Downloading Youtube videos by search result
On Fri, Apr 19, 2013 at 9:44 PM, Sayan Chatterjee wrote: > Dear All, > > I want to download some music from youtube.There are already marvellous > python scripts like youtube-dl which downloads videos and playlists from > numerous sites,but what I want to do is to download videos from youtube with > a search string. The user will give a search string, and the script will > download first 20(say) videos from the youtube.The script will use > youtube-dl on the backend and avconv tool for video to MP3 conversion etc. > > How should I proceed to make such a script. I am a newbie in Python but I am > sure with your guidance I can pick it up quite fast. :) May be take a look at the YouTube Data API? [1] Hopefully, the Getting Started section will help you [2]. [1] https://developers.google.com/youtube/1.0/developers_guide_python#SearchingVideos [2] https://developers.google.com/youtube/1.0/developers_guide_python#GettingStarted Best, Amit. -- http://amitsaha.github.com/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to find reverse pair words in a list of Words that has to be accessed through a URL
On 19/04/13 23:16, emile wrote: The gotcha with this approach is the border case of self paired words that aren't pairs. (pop,wow,mom,etc) yeah, but those exceptions are easy to catch as you generate the reversed list: if reversed(word) == word And its a bit of a moot point whether you should perhaps count a palindromic word as a pair of itself... -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to find reverse pair words in a list of Words that has to be accessed through a URL
On 20/04/13 09:57, Alan Gauld wrote: On 19/04/13 23:16, emile wrote: The gotcha with this approach is the border case of self paired words that aren't pairs. (pop,wow,mom,etc) yeah, but those exceptions are easy to catch as you generate the reversed list: if reversed(word) == word An easy mistake to make, but reversed() returns an iterator which will only compare equal to itself: py> reversed("abc") You need to convert the reversed object back into a string: py> "".join(reversed("abc")) 'cba' But the best way to reverse a string is with a slice: py> 'abc'[::-1] 'cba' The syntax is a little obscure, but "slicing" takes between 0 and 3 arguments, written inside square brackets [ ] and separated by colons. The full form of a slice is: string[start:end:step] where start defaults to the beginning of the string, end defaults to the end of the string, and step defaults to 1. If step is 1, you can leave it out: string[start:end] otherwise you need to include colons to mark the missing values: string[2::3] says to return a slice of the string, starting at character 2, going to the end, and taking every third character. (Remember that counting starts at 0 in Python, not 1, so character 2 is the *third* character.) py> "python is cool"[2::3] 'tnso' A negative step goes backwards, so a fast and efficient way to reverse a string or other sequence is to use slice it using [::-1]. And its a bit of a moot point whether you should perhaps count a palindromic word as a pair of itself... That word you use, I do not think it means what you think it means, to quote the Spaniard. A moot point is a point which is not relevant. If your house has just been flattened by a hurricane, it is a moot point whether or not you left the front door unlocked. I think it is quite relevant whether or not palindromes should count or not. -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to find reverse pair words in a list of Words that has to be accessed through a URL
On 20/04/13 01:48, Steven D'Aprano wrote: A moot point is a point which is not relevant. It most certainly is not. It is a point that is open to debate. Specifically it is a point that would be posted on the agenda for the weekly meetings in the local Moot Hall - the town guild/council's meeting place in medieval times. There are several towns in England where Moot Halls still exist and a few still have ceremonial Moot meetings where topics of local interest are occasionally debated. A fine example of a Moot Hall is in Aldeburgh in Suffolk: http://en.wikipedia.org/wiki/Aldeburgh [ And it must never, ever, be spelled a *mute* point - something that bugs me constantly since it infers almost the opposite of the real meaning! ] PS. On the subject of reversed() you are quite right although I wasn't thinking of python at the time I wrote it I was just indicating the algorithmic fix required to filter the palindromes. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor