Repository: ytdl-org/youtube-dl

Issue:
report: Unsupported URL (PressTV)
Thank you for this great tool. Works like a charm for me.

I would like to urge you to support this important URL.

Here ist my complete log:

[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['--verbose', 'http://www.presstv.ir/Video/2015/10/04/431915/Max-Igan-Press-TV-Face-to-Face']
[debug] Encodings: locale UTF-8, fs UTF-8, out None, pref UTF-8
[debug] youtube-dl version 2014.08.05
[debug] Python version 2.7.9 - Linux-3.16.0-4-amd64-x86_64-with-debian-8.2
[debug] Proxy map: {}
[generic] Max-Igan-Press-TV-Face-to-Face: Requesting header
WARNING: Falling back on generic information extractor.
[generic] Max-Igan-Press-TV-Face-to-Face: Downloading webpage
[generic] Max-Igan-Press-TV-Face-to-Face: Extracting information
ERROR: Unsupported URL: http://www.presstv.ir/Video/2015/10/04/431915/Max-Igan-Press-TV-Face-to-Face; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/generic.py", line 457, in _real_extract
    doc = parse_xml(webpage)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/utils.py", line 1417, in parse_xml
    return xml.etree.ElementTree.XML(s.encode('utf-8'), **kwargs)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1300, in XML
    parser.feed(text)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1642, in feed
    self._raiseerror(v)
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
    raise err
ParseError: mismatched tag: line 24, column 2
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 516, in extract_info
    ie_result = ie.extract(url)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 170, in extract
    return self._real_extract(url)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/generic.py", line 752, in _real_extract
    raise ExtractorError('Unsupported URL: %s' % url)
ExtractorError: Unsupported URL: http://www.presstv.ir/Video/2015/10/04/431915/Max-Igan-Press-TV-Face-to-Face; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.



Discussion:

Resolving patch:
diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py
--- a/youtube_dl/extractor/extractors.py
+++ b/youtube_dl/extractor/extractors.py
@@ -583,6 +583,7 @@
 from .pornotube import PornotubeIE
 from .pornovoisines import PornoVoisinesIE
 from .pornoxo import PornoXOIE
+from .presstv import PressTVIE
 from .primesharetv import PrimeShareTVIE
 from .promptfile import PromptFileIE
 from .prosiebensat1 import ProSiebenSat1IE
diff --git a/youtube_dl/extractor/presstv.py b/youtube_dl/extractor/presstv.py
new file mode 100644
--- /dev/null
+++ b/youtube_dl/extractor/presstv.py
@@ -0,0 +1,72 @@
+# coding: utf-8
+from __future__ import unicode_literals
+import re
+
+from .common import InfoExtractor
+from ..utils import str_to_int
+
+
+class PressTVIE(InfoExtractor):
+    _VALID_URL = r'https?://(?:www\.)?presstv\.ir/[^/]+/(?P<y>[0-9]+)/(?P<m>[0-9]+)/(?P<d>[0-9]+)/(?P<id>[0-9]+)/'
+
+    _TEST = {
+        'url': 'http://www.presstv.ir/Detail/2016/04/09/459911/Australian-sewerage-treatment-facility-/',
+        'md5': '5d7e3195a447cb13e9267e931d8dd5a5',
+        'info_dict': {
+            'id': '459911',
+            'ext': 'mp4',
+            'title': 'Organic mattresses used to clean waste water',
+            'upload_date': '20160409',
+            'thumbnail': 're:^https?://.*\.jpg',
+            'description': 'md5:20002e654bbafb6908395a5c0cfcd125'
+        }
+    }
+
+    def _real_extract(self, url):
+        video_id = self._match_id(url)
+        webpage = self._download_webpage(url, video_id)
+
+        # extract video URL from webpage
+        video_url = self._html_search_regex(r'<input type="hidden" id="inpPlayback" value="([^"]+)" />', webpage,
+                                            'Video URL')
+
+        # build list of available formats
+        # specified in http://www.presstv.ir/Scripts/playback.js
+        base_url = 'http://192.99.219.222:82/presstv'
+        _formats = [
+            ("180p", "_low200.mp4"),
+            ("360p", "_low400.mp4"),
+            ("720p", "_low800.mp4"),
+            ("1080p", ".mp4")
+        ]
+
+        formats = []
+        for fmt in _formats:
+            format_id, extension = fmt
+            formats.append({
+                'url': base_url + video_url[:-4] + extension,
+                'format_id': format_id
+            })
+
+        # extract video metadata
+        title = self._html_search_meta('title', webpage, 'Title', True)
+        title = title.partition('-')[2].strip()
+
+        thumbnail = self._og_search_thumbnail(webpage)
+        description = self._og_search_description(webpage)
+
+        match = re.match(PressTVIE._VALID_URL, url)
+        upload_date = '%04d%02d%02d' % (
+            str_to_int(match.group('y')),
+            str_to_int(match.group('m')),
+            str_to_int(match.group('d'))
+        )
+
+        return {
+            'id': video_id,
+            'title': title,
+            'formats': formats,
+            'thumbnail': thumbnail,
+            'upload_date': upload_date,
+            'description': description
+        }


Test patch: