SHARE
TWEET

Untitled

a guest May 25th, 2013 1,242 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top