Posts

Showing posts with the label python

Project Holy_Python_Grail_Quest - Argparse

In this post, I'll be sharing my notes on Argparse module on python. I've come across argparse module while working on my project. After googling, I've found this great tutorial at official python website:  https://docs.python.org/2/howto/argparse.html . If you go through this, you'll get a very good idea about argparse and its usage. I'm just posting this as a summarized version of what I've understood from the tutorial. Anyone can go through this for quick reference. Introducing Positional Arguments :  import argparse parser = argparse . ArgumentParser () parser . add_argument ( "square" , help = "display a square of a given number" , type = int ) args = parser . parse_args () print args . square ** 2 add_argument - To specify command line arguments the program is willing to accept parse_args() - returns some data from the options specified help - gives an idea about what the argument does a...

Project pyCountVids - Python Script To Count Total Videos in a Directory

So, I've started working on my long awaited project by implementing it in small increments. First, I've decided to write a python script that counts total videos in a directory and its sub-directory. #!/usr/bin/env python2 import os import sys rootDir = sys.argv[1] totalVideoCounter = 0 videoExtension = [".3g2", ".3gp", ".asf", ".asx", ".avi", ".flv", \                         ".m2ts", ".mkv", ".mov", ".mp4", ".mpg", ".mpeg", \                         ".rm", ".swf", ".vob", ".wmv", "m4v"] for dirPath, subdirList, fileList in os.walk(rootDir,topdown=False):     dirName = dirPath.split(os.path.sep)[-1]     videoCounter = 0         for fname in fileList:       if fname.endswith(tuple(videoExtension)):             videoCounter +=1           ...

Project Dumbledore - How to download YouTube Playlist on your system

Image
As, I was going through some great lectures available on YouTube, I thought of saving them all in a playlist and then downloading them all for offline viewing on my system. After googling for few minutes, I found this great command line program youtube-dl  to achieve this. It ticks all the right boxes - simple, open source, platform independent and python based. To install this on Ubuntu based systems, run the following command on your terminal: sudo apt-get install youtube-dl To download YouTube playlist, run the following command: youtube-dl -ctik   https://www.youtube.com/playlist?list=XXXXXX It has many other great features, be sure to explore them all. Though, I have found a problem that it downloads video and audio files separately and then combines them together in a single file leaving two extra files after each download which needs to be removed after the download is complete. I haven't looked into it to find the issue. If I find the solution, I will ...

Django import error - no module named django.conf.urls.defaults

This error occurs because django.conf.urls.defaults has been removed in Django 1.6. I encountered this error while working with django-uploadify. For newer version of Django can be fixed by changing the import to from django.conf.urls import patterns, url, include I hope this helps anyone facing this problem. Cheers, MG.