Repository: ytdl-org/youtube-dl

Issue:
add support for sexykarma.com (used in Reddit Gonewild postings)
> youtube-dl 'http://www.sexykarma.com/gonewild/video/taking-a-quick-pee-yHI70cOyIHt.html'
> [generic] taking-a-quick-pee-yHI70cOyIHt: Requesting header
> WARNING: Falling back on generic information extractor.
> [generic] taking-a-quick-pee-yHI70cOyIHt: Downloading webpage
> [generic] taking-a-quick-pee-yHI70cOyIHt: Extracting information
> ERROR: Unsupported URL: http://www.sexykarma.com/gonewild/video/taking-a-quick-pee-yHI70cOyIHt.html; 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.
> john@time Downloads> youtube-dl -v 'http://www.sexykarma.com/gonewild/video/taking-a-quick-pee-yHI70cOyIHt.html'
> [debug] System config: ['-t', '--restrict-filenames']
> [debug] User config: []
> [debug] Command-line args: ['-v', 'http://www.sexykarma.com/gonewild/video/taking-a-quick-pee-yHI70cOyIHt.html']
> [debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
> [debug] youtube-dl version 2014.10.05.2
> [debug] Python version 2.7.5 - Darwin-13.4.0-x86_64-i386-64bit
> [debug] Proxy map: {'http': 'http://127.0.0.1:8228', 'https': 'http://127.0.0.1:8228'}
> [generic] taking-a-quick-pee-yHI70cOyIHt: Requesting header
> WARNING: Falling back on generic information extractor.
> [generic] taking-a-quick-pee-yHI70cOyIHt: Downloading webpage
> [generic] taking-a-quick-pee-yHI70cOyIHt: Extracting information
> ERROR: Unsupported URL: http://www.sexykarma.com/gonewild/video/taking-a-quick-pee-yHI70cOyIHt.html; 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/local/bin/youtube-dl/youtube_dl/extractor/generic.py", line 540, in _real_extract
>     doc = parse_xml(webpage)
>   File "/usr/local/bin/youtube-dl/youtube_dl/utils.py", line 1550, in parse_xml
>     tree = xml.etree.ElementTree.XML(s.encode('utf-8'), **kwargs)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1300, in XML
>     parser.feed(text)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1642, in feed
>     self._raiseerror(v)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
>     raise err
> ParseError: mismatched tag: line 317, column 37
> Traceback (most recent call last):
>   File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 524, in extract_info
>     ie_result = ie.extract(url)
>   File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 193, in extract
>     return self._real_extract(url)
>   File "/usr/local/bin/youtube-dl/youtube_dl/extractor/generic.py", line 907, in _real_extract
>     raise ExtractorError('Unsupported URL: %s' % url)
> ExtractorError: Unsupported URL: http://www.sexykarma.com/gonewild/video/taking-a-quick-pee-yHI70cOyIHt.html; 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/__init__.py b/youtube_dl/extractor/__init__.py
--- a/youtube_dl/extractor/__init__.py
+++ b/youtube_dl/extractor/__init__.py
@@ -316,6 +316,7 @@
 from .scivee import SciVeeIE
 from .screencast import ScreencastIE
 from .servingsys import ServingSysIE
+from .sexykarma import SexyKarmaIE
 from .shared import SharedIE
 from .sharesix import ShareSixIE
 from .sina import SinaIE
diff --git a/youtube_dl/extractor/sexykarma.py b/youtube_dl/extractor/sexykarma.py
new file mode 100644
--- /dev/null
+++ b/youtube_dl/extractor/sexykarma.py
@@ -0,0 +1,77 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+import re
+import datetime
+
+class SexyKarmaIE(InfoExtractor):
+    _VALID_URL = r'https?://(?:www\.)?sexykarma\.com/gonewild/video/.+\-(?P<id>[a-zA-Z0-9\-]+)(.html)'
+    _TESTS = [{
+        'url': 'http://www.sexykarma.com/gonewild/video/taking-a-quick-pee-yHI70cOyIHt.html',
+        'md5': 'b9798e7d1ef1765116a8f516c8091dbd',
+        'info_dict': {
+            'id': 'yHI70cOyIHt',
+            'ext': 'mp4',
+            'title': 'Taking a quick pee.',
+            'uploader_id': 'wildginger7',
+            'thumbnail': 're:^https?://.*\.jpg$',
+            'duration': int,
+            'view_count': int,
+            'upload_date': '20141007',
+        }
+    }, {
+        'url': 'http://www.sexykarma.com/gonewild/video/pot-pixie-tribute-8Id6EZPbuHf.html',
+        'md5': 'dd216c68d29b49b12842b9babe762a5d',
+        'info_dict': {
+            'id': '8Id6EZPbuHf',
+            'ext': 'mp4',
+            'title': 'pot_pixie tribute',
+            'uploader_id': 'banffite',
+            'thumbnail': 're:^https?://.*\.jpg$',
+            'duration': int,
+            'view_count': int,
+            'upload_date': '20141013',
+        }
+    }]
+
+    def _real_extract(self, url):
+        video_id = self._match_id(url)
+
+        webpage = self._download_webpage(url, video_id)
+              
+        title = self._html_search_regex(r'<h2 class="he2"><span>(.*?)</span>', webpage, 'title')
+        uploader_id = self._html_search_regex(r'class="aupa">\n*(.*?)</a>', webpage, 'uploader')
+        url = self._html_search_regex(r'<p><a href="(.*?)" ?\n*target="_blank"><font color', webpage, 'url')
+        thumbnail = self._html_search_regex(r'<div id="player" style="z-index:1;"> <span id="edge"></span> <span id="container"><img[\n ]*src="(.+?)"', webpage, 'thumbnail')
+        
+        str_duration = self._html_search_regex(r'<tr>[\n\s]*<td>Time: </td>[\n\s]*<td align="right"><span>(.+)\n*', webpage, 'duration')
+        duration = self._to_seconds(str_duration)
+
+        str_views = self._html_search_regex(r'<tr>[\n\s]*<td>Views: </td>[\n\s]*<td align="right"><span>(.+)</span>', webpage, 'view_count')
+        view_count = int(str_views)
+        # print view_count
+
+        date = self._html_search_regex(r'class="aup">Added: <strong>(.*?)</strong>', webpage, 'date')
+        d = datetime.datetime.strptime(date, '%B %d, %Y')
+        upload_date = d.strftime('%Y%m%d')
+
+        categories = re.findall(r'http://www.sexykarma.com/gonewild/search/video/(?:.+?)"><span>(.*?)</span>', webpage)
+
+        return {
+            'id': video_id,
+            'title': title,
+            'uploader_id': uploader_id,
+            'url': url,
+            'thumbnail': thumbnail,
+            'duration': duration,
+            'view_count': view_count,
+            'upload_date': upload_date,
+            'categories': categories,
+        }
+
+    def _to_seconds(self, timestr):
+        seconds= 0
+        for part in timestr.split(':'):
+            seconds= seconds*60 + int(part)
+        return seconds


Test patch: