Advertisement
Guest User

Untitled

a guest
May 25th, 2013
1,357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. #nrk_stream.py
  2. import urllib2
  3. import re
  4. import subprocess
  5.  
  6. def nrk(url, vid_quality,f_name):
  7.     quality = {'low' : 'index_2',
  8.                'med' : 'index_3',
  9.                'high': 'index_4'}
  10.     url = urllib2.urlopen(url).read()
  11.     link = re.search(r'data-media="(.*)manifest', url)
  12.     link = link.group(1)
  13.     link = re.sub(r'/\w/', '/i/', link)
  14.     link_add = quality[vid_quality]+'_av.m3u8?null=#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2390000,RESOLUTION=1280x720'
  15.     fin_link = '{}{}'.format(link, link_add)
  16.     #Run cmd commands
  17.     process = subprocess.Popen('cmd.exe /k ', shell=True, stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=None)
  18.     process.stdin.write("ffmpeg -i {} -c copy {}\n".format(fin_link, '{}.mkv'.format(f_name)))
  19.     o,e=process.communicate()
  20.     process.stdin.close()
  21.  
  22. if __name__ == '__main__':
  23.     #---|Only make changes here|---#
  24.     #Paste in url from nrk video you want to download
  25.     url = 'http://tv.nrk.no/serie/tegnspraaknytt/nnfa91052413/24-05-2013'
  26.  
  27.     #Video quality,default set to medium(low med high)
  28.     vid_quality = 'med'
  29.     #Name of file,default is set to test.mkv
  30.     f_name = 'test'
  31.     nrk(url, vid_quality, f_name)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement