Example #1
0
    def test_padding(self):
        """Test that proper padding is done in the VideoItem.buildCommandList method"""
        youtube_video = parser_manager.validateURL(test_dict["youtube"])
        youtube_video.title = "Tester"
        youtube_video.setFilePaths(".")
        # youtube_video.setOutputRes (youtube_video.RES_640)

        # Testing against http://www.youtube.com/watch?v=_leYvPpmJGg specs
        command_list = youtube_video.buildCommandList(96, 384, 320, 180)
        padtop = padbottom = None
        for i, value in enumerate(command_list):
            if value == "-padtop":
                padtop = command_list[i + 1]
            elif value == "-padbottom":
                padbottom = command_list[i + 1]

        self.assertEqual(padtop, "30")
        self.assertEqual(padbottom, "30")

        # Testing against http://www.giantbomb.com/50-cent-blood-on-the-sand-video-review/17-289/ specs
        command_list = youtube_video.buildCommandList(96, 384, 640, 368)
        padtop = padbottom = None
        for i, value in enumerate(command_list):
            if value == "-padtop":
                padtop = command_list[i + 1]
            elif value == "-padbottom":
                padbottom = command_list[i + 1]

        self.assertEqual(padtop, "28")
        self.assertEqual(padbottom, "28")

        # Testing against http://video.google.com/videoplay?docid=-8378365891276905720
        # specs
        command_list = youtube_video.buildCommandList(96, 384, 200, 240)
        padleft = padright = None
        for i, value in enumerate(command_list):
            if value == "-padleft":
                padleft = command_list[i + 1]
            elif value == "-padright":
                padright = command_list[i + 1]

        self.assertEqual(padleft, "60")
        self.assertEqual(padright, "60")
Example #2
0
    def test_padding(self):
        """Test that proper padding is done in the VideoItem.buildCommandList method"""
        youtube_video = parser_manager.validateURL(test_dict["youtube"])
        youtube_video.title = "Tester"
        youtube_video.setFilePaths(".")
        #youtube_video.setOutputRes (youtube_video.RES_640)

        # Testing against http://www.youtube.com/watch?v=_leYvPpmJGg specs
        command_list = youtube_video.buildCommandList(96, 384, 320, 180)
        padtop = padbottom = None
        for i, value in enumerate(command_list):
            if value == "-padtop": padtop = command_list[i + 1]
            elif value == "-padbottom": padbottom = command_list[i + 1]

        self.assertEqual(padtop, "30")
        self.assertEqual(padbottom, "30")

        # Testing against http://www.giantbomb.com/50-cent-blood-on-the-sand-video-review/17-289/ specs
        command_list = youtube_video.buildCommandList(96, 384, 640, 368)
        padtop = padbottom = None
        for i, value in enumerate(command_list):
            if value == "-padtop": padtop = command_list[i + 1]
            elif value == "-padbottom": padbottom = command_list[i + 1]

        self.assertEqual(padtop, "28")
        self.assertEqual(padbottom, "28")

        # Testing against http://video.google.com/videoplay?docid=-8378365891276905720
        # specs
        command_list = youtube_video.buildCommandList(96, 384, 200, 240)
        padleft = padright = None
        for i, value in enumerate(command_list):
            if value == "-padleft": padleft = command_list[i + 1]
            elif value == "-padright": padright = command_list[i + 1]

        self.assertEqual(padleft, "60")
        self.assertEqual(padright, "60")
Example #3
0
    if "XDG_DATA_DIRS" in os.environ:
        data_dirs = os.environ["XDG_DATA_DIRS"].split(":")
        for data_dir in data_dirs:
            media_paths.append(os.path.join(data_dir, "youtubed-2x"))
    elif WINDOWS:
        media_paths.append(os.path.join(sys.prefix, "share", "youtubed-2x"))

    app_settings = settings.Settings()
    try:
        app_settings.readConfigFile()
    except app_settings.InvalidConfig as exception:
        logging.exception("Invalid configuration file")
        logging.info("Reverting to default settings")
        app_settings.setDefaults()

    parser_manager.importParsers()

    gladefile = None
    filename = "youtubed-2x.glade"
    for path in media_paths:
        glade_file = os.path.join(path, filename)
        if os.path.exists(glade_file):
            gladefile = glade_file
            break

    if not gladefile:
        logging.critical('Glade file "%s" could not be found. Exiting.', filename)
        sys.exit(1)

    thread_manager = VideoThreadManager(app_settings)
    prop_win = PropertiesWindow(gladefile, app_settings)
Example #4
0
 def _get_information(self, url):
     video = parser_manager.validateURL(url)
     self.assert_(video, "The URL {0} tested was invalid".format(url))
     video.getVideoInformation()
Example #5
0
 def _get_information(self, url):
     video = parser_manager.validateURL(url)
     self.assert_(video, "The URL {0} tested was invalid".format(url))
     video.getVideoInformation()
Example #6
0
class ParserTest(unittest.TestCase):
    parser_manager.importParsers()

    def test_page_download(self):
        """Test the page downloader function. Attempt to download the
           page for a YouTube video"""
        page, newurl = other.getPage(test_dict["youtube"])
        self.assert_(page)

    def _get_information(self, url):
        video = parser_manager.validateURL(url)
        self.assert_(video, "The URL {0} tested was invalid".format(url))
        video.getVideoInformation()

    def test_youtube_parser(self):
        url = test_dict["youtube"]
        self._get_information(url)

    def test_pornotube_parser(self):
        url = test_dict["pornotube"]
        self._get_information(url)

    def test_redtube_parser(self):
        url = test_dict["redtube"]
        self._get_information(url)

    def test_veoh_parser(self):
        url = test_dict["veoh"]
        self._get_information(url)

    def test_veoh_portal_parser(self):
        url = test_dict["veoh_portal"]
        self._get_information(url)

    def test_youporn_parser(self):
        url = test_dict["youporn"]
        self._get_information(url)

    def test_google_video_parser(self):
        url = test_dict["google_video"]
        self._get_information(url)

    def test_metacafe_parser(self):
        url = test_dict["metacafe"]
        self._get_information(url)

    def test_pornhub_parser(self):
        url = test_dict["pornhub"]
        self._get_information(url)

    def test_tube8_parser(self):
        url = test_dict["tube8"]
        self._get_information(url)

    def test_myvideo_parser(self):
        url = test_dict["myvideo"]
        self._get_information(url)

    def test_myspacetv_parser(self):
        url = test_dict["myspacetv"]
        self._get_information(url)

    def test_guba_parser(self):
        url = test_dict["guba"]
        self._get_information(url)

    def test_dailymotion_parser(self):
        url = test_dict["dailymotion"]
        self._get_information(url)

    def test_giantbomb_parser(self):
        url = test_dict["giantbomb"]
        self._get_information(url)

    def test_screwattack_parser(self):
        url = test_dict["screwattack"]
        self._get_information(url)

    def test_gametrailers_parser(self):
        url = test_dict["gametrailers"]
        self._get_information(url)

    def test_escapistmagazine_parser(self):
        url = test_dict["escapistmagazine"]
        self._get_information(url)

    def test_yahoovideo_parser(self):
        url = test_dict["yahoovideo"]
        self._get_information(url)

    def test_padding(self):
        """Test that proper padding is done in the VideoItem.buildCommandList method"""
        youtube_video = parser_manager.validateURL(test_dict["youtube"])
        youtube_video.title = "Tester"
        youtube_video.setFilePaths(".")
        #youtube_video.setOutputRes (youtube_video.RES_640)

        # Testing against http://www.youtube.com/watch?v=_leYvPpmJGg specs
        command_list = youtube_video.buildCommandList(96, 384, 320, 180)
        padtop = padbottom = None
        for i, value in enumerate(command_list):
            if value == "-padtop": padtop = command_list[i + 1]
            elif value == "-padbottom": padbottom = command_list[i + 1]

        self.assertEqual(padtop, "30")
        self.assertEqual(padbottom, "30")

        # Testing against http://www.giantbomb.com/50-cent-blood-on-the-sand-video-review/17-289/ specs
        command_list = youtube_video.buildCommandList(96, 384, 640, 368)
        padtop = padbottom = None
        for i, value in enumerate(command_list):
            if value == "-padtop": padtop = command_list[i + 1]
            elif value == "-padbottom": padbottom = command_list[i + 1]

        self.assertEqual(padtop, "28")
        self.assertEqual(padbottom, "28")

        # Testing against http://video.google.com/videoplay?docid=-8378365891276905720
        # specs
        command_list = youtube_video.buildCommandList(96, 384, 200, 240)
        padleft = padright = None
        for i, value in enumerate(command_list):
            if value == "-padleft": padleft = command_list[i + 1]
            elif value == "-padright": padright = command_list[i + 1]

        self.assertEqual(padleft, "60")
        self.assertEqual(padright, "60")
Example #7
0
    sys.exit(42)

# Create the default videos directory if one does not exist
if WINDOWS:
    videos_dir = os.path.join(path, "My Documents", "My Videos")
else:
    videos_dir = os.path.join(path, "Videos")

if not os.path.isdir(videos_dir):
    try:
        os.mkdir(videos_dir)
    except OSError:
        print >> sys.stderr, "Could not make videos directory. Exiting."
        sys.exit(42)

parser_manager.importParsers()
#### Iterate through the list of URLs and download  ####
#### and transcode any specified videos             ####
for full_url in command_args:
    print
    youtube_video = parser_manager.validateURL(full_url)
    if not youtube_video:
        print >> sys.stderr, "An invalid url (%s) was passed. Exiting." % full_url
        sys.exit(42)

    try:
        youtube_video.getVideoInformation()
    except (youtube_video.parser.UnknownTitle,
            youtube_video.parser.InvalidCommands, PageNotFound,
            youtube_video.parser.URLBuildFailed,
            youtube_video.parser.InvalidPortal) as e:
Example #8
0
    if "XDG_DATA_DIRS" in os.environ:
        data_dirs = os.environ["XDG_DATA_DIRS"].split(":")
        for data_dir in data_dirs:
            media_paths.append(os.path.join(data_dir, "youtubed-2x"))
    elif WINDOWS:
        media_paths.append(os.path.join(sys.prefix, "share", "youtubed-2x"))

    app_settings = settings.Settings()
    try:
        app_settings.readConfigFile()
    except app_settings.InvalidConfig as exception:
        logging.exception("Invalid configuration file")
        logging.info("Reverting to default settings")
        app_settings.setDefaults()

    parser_manager.importParsers()

    gladefile = None
    filename = "youtubed-2x.glade"
    for path in media_paths:
        glade_file = os.path.join(path, filename)
        if os.path.exists(glade_file):
            gladefile = glade_file
            break

    if not gladefile:
        logging.critical("Glade file \"%s\" could not be found. Exiting.",
                         filename)
        sys.exit(1)

    thread_manager = VideoThreadManager(app_settings)
Example #9
0
# Create the default videos directory if one does not exist
if WINDOWS:
    videos_dir = os.path.join (path, "My Documents", "My Videos")
else:
    videos_dir = os.path.join (path, "Videos")

if not os.path.isdir (videos_dir):
    try:
        os.mkdir (videos_dir)
    except OSError:
        print >> sys.stderr, "Could not make videos directory. Exiting."
        sys.exit (42)


parser_manager.importParsers ()
#### Iterate through the list of URLs and download  ####
#### and transcode any specified videos             ####
for full_url in command_args:
    print
    youtube_video = parser_manager.validateURL (full_url)
    if not youtube_video:
        print >> sys.stderr, "An invalid url (%s) was passed. Exiting." % full_url
        sys.exit (42)

    try:
        youtube_video.getVideoInformation ()
    except (youtube_video.parser.UnknownTitle, youtube_video.parser.InvalidCommands,
            PageNotFound, youtube_video.parser.URLBuildFailed, youtube_video.parser.InvalidPortal) as e:
        print >> sys.stderr, "%s. Exiting." % e.message
        sys.exit (42)