def test_get_stream_from_supported_multi_resolution_site_returns_properly_formatted_url(
         self):
     """ Tests a stream grab from YouTube, a site specifically supported
     with multiple resolutions"""
     src_url = fsrc.get_stream_src_from_url(
         'https://www.youtube.com/watch?v=jlD3vw0LRSI')
     self.assertTrue(src_url.startswith('http://manifest.googlevideo.com/'))
     self.assertTrue(src_url.endswith('.m3u8'))
 def test_get_stream_from_supported_single_resolution_site_returns_properly_formatted_url(
         self):
     """Tests a stream grab from uLive, a specifically supported site.
     Also ensures that when no 'best' stream exists, a stream is still selected"""
     src_url = fsrc.get_stream_src_from_url(
         'http://www.ustream.tv/channel/apl-specials')
     self.assertTrue(src_url.startswith('http://'))
     self.assertTrue('.m3u8' in src_url)
     self.assertTrue('ustream.tv' in src_url)
Esempio n. 3
0
Command to run script: python3 loop.py
Usage                : Can be imported into another script or run from the command line
Input file format    : N/A
Output               : A list of m3u8 urls
Note                 : This is only the initial script for getting all the m3u8 urls, it will stuck everytime it encounters an url of RTMP type, so I had to run fetchstreamsrc.py manually to get the information of those urls with issues. The next step is to identify the urls of RTMP type and deal with them specifically.
Other files required by : fetchstreamsrc.py (written by Caleb)
this script and where 
located
--------------------------------------------------------------------------------
"""

import streamlink
from bs4 import BeautifulSoup
from fetchstreamsrc import get_stream_src_from_url
import re
import sys
import string
import traceback

#read lines from earthcamURL
with open('earthcamURL.txt') as f:
    page_url = []
    page_url = f.readlines()
    #loop through every line in the list
    for line in page_url:
        src_url = []
        #transform the original urls into m3u8 ones using the function in fetchstreamsrc.py
        src_url = get_stream_src_from_url(line)
        print(src_url)
    print("m3u8 url: %s", src_url)
 def test_get_stream_from_malformed_url_string_returns_none(self):
     """Tests that None is returned when the provided page URL is malformed"""
     self.assertIsNone(
         fsrc.get_stream_src_from_url('httpbustedwebsitestring'))
    def test_get_stream_from_no_livestream_site_returns_none(self):
        """Tests that None is returned when the site contains no livestream."""

        self.assertIsNone(fsrc.get_stream_src_from_url('http://calebtung.com'))
 def test_get_stream_unsupported_site_returns_properly_formatted_url(self):
     """ Tests a stream grab from Earthcam, a site not specifically supported"""
     src_url = fsrc.get_stream_src_from_url(
         'http://www.earthcam.com/usa/newyork/timessquare/?cam=tsrobo1')
     self.assertTrue(src_url.startswith('http://video3.earthcam.com/'))
     self.assertTrue(src_url.endswith('.m3u8'))