python script to fetch rss feeds

I was just thinking about making an rss bot in telegram, and wrote a small python script which can fetch rss feeds from the feed link and prints the result with “Title” and “Link”.

import feedparser
import sys

if len(sys.argv) < 2:
print("USAGE: python feedparse.py <rss feed link>")
exit()

rss_url = sys.argv[1]
print("TITLE","                                                   ","LINK")
print("------------------------------------------------------------------")

feed = feedparser.parse( rss_url )

y = len(feed[ "items" ])

for x in range(0,y):
print('\033[91m'+feed[ "items" ][x][ "title" ] + '\033[0m', "-", feed[ "items" ][x][ "link" ])

Below example shall print the feeds available in Mobilecrunch.

Example:
$ python feedparse.py http://feeds.feedburner.com/Mobilecrunch

Newest code will be available in gist if I forget to update this blog.

Advertisements

Extract mp3 from youtube-dl

There is a famous command line tool called youtube-dl to download videos from youtube, and its an opensource project written in python and available for Linux, windows and OSX platforms.

In Linux, you can install the tool using:

$ sudo pip install –upgrade youtube-dl

To download a video from a link:

$ youtube-dl <Your Video link>

Example: youtube-dl https://www.youtube.com/watch?v=pRpeEdMmmQ0&list=RDpRpeEdMmmQ0

It will get donwloaded in $PWD.

To download mp3 from a link:

$ youtube-dl –extract-audio –audio-format mp3 <Your Video Link>

Example: youtube-dl –extract-audio –audio-format mp3 https://www.youtube.com/watch?v=krpm0DaeLnI

It will get downloaded in $PWD.

Do “youtube-dl -h” for more help on formats and other features.

 

Download audio from soundcloud through command line

Like youtube-dl there is a command line tool called scdl, which is written in python based on GPLV2 license and works on Linux, windows and OSX.

To install in linux, execute below command:

$ pip install scdl

To download a single song:

$scdl -l <Sound cloud link to the song>

Example: scdl -l scdl -l https://soundcloud.com/trdp/raghu-dixit-jagchanga-lokada

It will download and store in $PWD

Do “scdl -h” to know other options like download complete album, user liked videos etc.