Hello community,

here is the log from the commit of package you-get for openSUSE:Factory checked 
in at 2018-08-10 09:49:28
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/you-get (Old)
 and      /work/SRC/openSUSE:Factory/.you-get.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "you-get"

Fri Aug 10 09:49:28 2018 rev:8 rq:628203 version:0.4.1120

Changes:
--------
--- /work/SRC/openSUSE:Factory/you-get/you-get.changes  2018-06-29 
22:35:51.302030222 +0200
+++ /work/SRC/openSUSE:Factory/.you-get.new/you-get.changes     2018-08-10 
09:49:29.742242650 +0200
@@ -1,0 +2,5 @@
+Wed Aug  8 16:31:07 UTC 2018 - aloi...@gmx.com
+
+- Update to version 0.4.1120 (no changelog supplied)
+
+-------------------------------------------------------------------

Old:
----
  you-get-0.4.1099.tar.gz

New:
----
  you-get-0.4.1120.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ you-get.spec ++++++
--- /var/tmp/diff_new_pack.wUhT7S/_old  2018-08-10 09:49:30.398243707 +0200
+++ /var/tmp/diff_new_pack.wUhT7S/_new  2018-08-10 09:49:30.398243707 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           you-get
-Version:        0.4.1099
+Version:        0.4.1120
 Release:        0
 Summary:        Dumb downloader that scrapes the web
 License:        MIT

++++++ you-get-0.4.1099.tar.gz -> you-get-0.4.1120.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/common.py 
new/you-get-0.4.1120/src/you_get/common.py
--- old/you-get-0.4.1099/src/you_get/common.py  2018-06-27 23:35:15.000000000 
+0200
+++ new/you-get-0.4.1120/src/you_get/common.py  2018-08-08 17:12:11.000000000 
+0200
@@ -143,7 +143,7 @@
     'Accept-Charset': 'UTF-8,*;q=0.5',
     'Accept-Encoding': 'gzip,deflate,sdch',
     'Accept-Language': 'en-US,en;q=0.8',
-    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) 
Gecko/20100101 Firefox/51.0',  # noqa
+    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) 
Gecko/20100101 Firefox/60.0',  # noqa
 }
 
 if sys.stdout.isatty():
@@ -369,13 +369,16 @@
         return data
 
 
-def get_location(url):
+def get_location(url, headers=None, get_method='HEAD'):
     logging.debug('get_location: %s' % url)
 
-    response = request.urlopen(url)
-    # urllib will follow redirections and it's too much code to tell urllib
-    # not to do that
-    return response.geturl()
+    if headers:
+        req = request.Request(url, headers=headers)
+    else:
+        req = request.Request(url)
+    req.get_method = lambda: get_method
+    res = urlopen_with_retry(req)
+    return res.geturl()
 
 
 def urlopen_with_retry(*args, **kwargs):
@@ -496,7 +499,7 @@
     return sum([url_size(url, faker=faker, headers=headers) for url in urls])
 
 
-def get_head(url, headers={}, get_method='HEAD'):
+def get_head(url, headers=None, get_method='HEAD'):
     logging.debug('get_head: %s' % url)
 
     if headers:
@@ -505,7 +508,7 @@
         req = request.Request(url)
     req.get_method = lambda: get_method
     res = urlopen_with_retry(req)
-    return dict(res.headers)
+    return res.headers
 
 
 def url_info(url, faker=False, headers={}):
@@ -1594,15 +1597,11 @@
             url
         )
     else:
-        import http.client
-        video_host = r1(r'https?://([^/]+)/', url)  # .cn could be removed
-        if url.startswith('https://'):
-            conn = http.client.HTTPSConnection(video_host)
-        else:
-            conn = http.client.HTTPConnection(video_host)
-        conn.request('HEAD', video_url, headers=fake_headers)
-        res = conn.getresponse()
-        location = res.getheader('location')
+        try:
+            location = get_location(url) # t.co isn't happy with fake_headers
+        except:
+            location = get_location(url, headers=fake_headers)
+
         if location and location != url and not location.startswith('/'):
             return url_to_module(location)
         else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/extractors/baidu.py 
new/you-get-0.4.1120/src/you_get/extractors/baidu.py
--- old/you-get-0.4.1099/src/you_get/extractors/baidu.py        2018-06-27 
23:35:15.000000000 +0200
+++ new/you-get-0.4.1120/src/you_get/extractors/baidu.py        2018-08-08 
17:12:11.000000000 +0200
@@ -129,7 +129,7 @@
             html = get_html(url)
             title = r1(r'title:"([^"]+)"', html)
 
-            vhsrc = re.findall(r'vhsrc="([^"]+)"', html)
+            vhsrc = re.findall(r'"BDE_Image"[^>]+src="([^"]+)"', html) or 
re.findall(r'vhsrc="([^"]+)"', html)
             if vhsrc is not None:
                 ext = 'mp4'
                 size = url_size(vhsrc[0])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/extractors/bilibili.py 
new/you-get-0.4.1120/src/you_get/extractors/bilibili.py
--- old/you-get-0.4.1099/src/you_get/extractors/bilibili.py     2018-06-27 
23:35:15.000000000 +0200
+++ new/you-get-0.4.1120/src/you_get/extractors/bilibili.py     2018-08-08 
17:12:11.000000000 +0200
@@ -137,9 +137,18 @@
             m = re.search(r'property="og:title" content="([^"]+)"', self.page)
             if m is not None:
                 self.title = m.group(1)
+
         if 'subtitle' in kwargs:
             subtitle = kwargs['subtitle']
             self.title = '{} {}'.format(self.title, subtitle)
+        else:
+            playinfo = re.search(r'__INITIAL_STATE__=(.*?);\(function\(\)', 
self.page)
+            if playinfo is not None:
+                pages = json.loads(playinfo.group(1))['videoData']['pages']
+                if len(pages) > 1:
+                    qs = 
dict(parse.parse_qsl(urllib.parse.urlparse(self.url).query))
+                    page = pages[int(qs.get('p', 1)) - 1]
+                    self.title = '{} #{}. {}'.format(self.title, page['page'], 
page['part'])
 
         if 'bangumi.bilibili.com/movie' in self.url:
             self.movie_entry(**kwargs)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/extractors/instagram.py 
new/you-get-0.4.1120/src/you_get/extractors/instagram.py
--- old/you-get-0.4.1099/src/you_get/extractors/instagram.py    2018-06-27 
23:35:15.000000000 +0200
+++ new/you-get-0.4.1120/src/you_get/extractors/instagram.py    2018-08-08 
17:12:11.000000000 +0200
@@ -29,6 +29,7 @@
                 image_url = edge['node']['display_url']
                 if 'video_url' in edge['node']:
                     image_url = edge['node']['video_url']
+                image_url = image_url.split('?')[0]
                 ext = image_url.split('.')[-1]
                 size = int(get_head(image_url)['Content-Length'])
                 print_info(site_info, title, ext, size)
@@ -43,6 +44,7 @@
             image_url = 
info['entry_data']['PostPage'][0]['graphql']['shortcode_media']['display_url']
             if 'video_url' in 
info['entry_data']['PostPage'][0]['graphql']['shortcode_media']:
                 image_url 
=info['entry_data']['PostPage'][0]['graphql']['shortcode_media']['video_url']
+            image_url = image_url.split('?')[0]
             ext = image_url.split('.')[-1]
             size = int(get_head(image_url)['Content-Length'])
             print_info(site_info, title, ext, size)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/extractors/kugou.py 
new/you-get-0.4.1120/src/you_get/extractors/kugou.py
--- old/you-get-0.4.1099/src/you_get/extractors/kugou.py        2018-06-27 
23:35:15.000000000 +0200
+++ new/you-get-0.4.1120/src/you_get/extractors/kugou.py        2018-08-08 
17:12:11.000000000 +0200
@@ -20,32 +20,69 @@
         print_info(site_info, title, songtype, size)
         if not info_only:
             download_urls([url], title, ext, size, output_dir, merge=merge)
+    elif url.lower().find("hash")!=-1:
+        return kugou_download_by_hash(url,output_dir,merge,info_only)
     else:
         #for the www.kugou.com/
         return kugou_download_playlist(url, output_dir=output_dir, 
merge=merge, info_only=info_only)
         # raise NotImplementedError(url)       
 
-def kugou_download_by_hash(title,hash_val,output_dir = '.', merge = True, 
info_only = False):
+
+def kugou_download_by_hash(url,output_dir = '.', merge = True, info_only = 
False):
     #sample
-    #url_sample:http://www.kugou.com/yy/album/single/536957.html
-    #hash ->key  md5(hash+kgcloud")->key  decompile swf
-    #cmd 4 for mp3 cmd 3 for m4a
-    key=hashlib.new('md5',(hash_val+"kgcloud").encode("utf-8")).hexdigest()
-    
html=get_html("http://trackercdn.kugou.com/i/?pid=6&key=%s&acceptMp3=1&cmd=4&hash=%s"%(key,hash_val))
-    j=loads(html)
-    url=j['url']
+    
#url_sample:http://www.kugou.com/song/#hash=93F7D2FC6E95424739448218B591AEAF&album_id=9019462
+    hash_val = match1(url,'hash=(\w+)')
+    album_id = match1(url,'album_id=(\d+)')
+    html = 
get_html("http://www.kugou.com/yy/index.php?r=play/getdata&hash={}&album_id={}".format(hash_val,album_id))
+    j =loads(html)
+    url = j['data']['play_url']
+    title = j['data']['audio_name']
+    # some songs cann't play because of copyright protection
+    if(url == ''):
+        return
     songtype, ext, size = url_info(url)
     print_info(site_info, title, songtype, size)
     if not info_only:
         download_urls([url], title, ext, size, output_dir, merge=merge)
 
 def kugou_download_playlist(url, output_dir = '.', merge = True, info_only = 
False, **kwargs):
-    html=get_html(url)
-    pattern=re.compile('title="(.*?)".* data="(\w*)\|.*?"')
-    pairs=pattern.findall(html)
-    for title,hash_val in pairs:
-        kugou_download_by_hash(title,hash_val,output_dir,merge,info_only)
+    urls=[]
+    
+    #download music leaderboard
+    #sample: http://www.kugou.com/yy/html/rank.html
+    if url.lower().find('rank') !=-1:
+        html=get_html(url)
+        pattern = re.compile('<a href="(http://.*?)" data-active=')
+        res = pattern.findall(html)
+        for song in res:
+            res = get_html(song)
+            pattern_url = re.compile('"hash":"(\w+)".*"album_id":(\d)+')
+            hash_val,album_id= res = pattern_url.findall(res)[0]
+            
urls.append('http://www.kugou.com/song/#hash=%s&album_id=%s'%(hash_val,album_id))
+    
+    # download album
+    # album sample:   http://www.kugou.com/yy/album/single/1645030.html
+    elif url.lower().find('album')!=-1:
+        html = get_html(url)
+        pattern = re.compile('var data=(\[.*?\]);')
+        res = pattern.findall(html)[0]
+        for v in json.loads(res):
+            
urls.append('http://www.kugou.com/song/#hash=%s&album_id=%s'%(v['hash'],v['album_id']))
+
+    # download the playlist        
+    # playlist sample:http://www.kugou.com/yy/special/single/487279.html
+    else:
+        html = get_html(url)
+        pattern = re.compile('data="(\w+)\|(\d+)"')
+        for v in pattern.findall(html):
+            
urls.append('http://www.kugou.com/song/#hash=%s&album_id=%s'%(v[0],v[1]))
+            print('http://www.kugou.com/song/#hash=%s&album_id=%s'%(v[0],v[1]))
+
+    #download the list by hash
+    for url in urls:
+        kugou_download_by_hash(url,output_dir,merge,info_only)
 
+                
 
 site_info = "kugou.com"
 download = kugou_download
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/extractors/miaopai.py 
new/you-get-0.4.1120/src/you_get/extractors/miaopai.py
--- old/you-get-0.4.1099/src/you_get/extractors/miaopai.py      2018-06-27 
23:35:15.000000000 +0200
+++ new/you-get-0.4.1120/src/you_get/extractors/miaopai.py      2018-08-08 
17:12:11.000000000 +0200
@@ -31,7 +31,7 @@
 
 #----------------------------------------------------------------------
 def miaopai_download(url, output_dir = '.', merge = False, info_only = False, 
**kwargs):
-    fid = match1(url, r'\?fid=(\d{4}:\w{32})')
+    fid = match1(url, r'\?fid=(\d{4}:\w+)')
     if fid is not None:
         miaopai_download_by_fid(fid, output_dir, merge, info_only)
     elif '/p/230444' in url:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/extractors/qq.py 
new/you-get-0.4.1120/src/you_get/extractors/qq.py
--- old/you-get-0.4.1099/src/you_get/extractors/qq.py   2018-06-27 
23:35:15.000000000 +0200
+++ new/you-get-0.4.1120/src/you_get/extractors/qq.py   2018-08-08 
17:12:11.000000000 +0200
@@ -2,28 +2,25 @@
 
 __all__ = ['qq_download']
 
-from ..common import *
-from ..util.log import *
 from .qie import download as qieDownload
 from .qie_video import download_by_url as qie_video_download
-from urllib.parse import urlparse,parse_qs
-
-def qq_download_by_vid(vid, title, default_from, output_dir='.', merge=True, 
info_only=False):
+from ..common import *
 
-    if default_from:
-        platform = 11
-    else:
-        # fix return {,"msg":"cannot play outside"}
-        platform = 4100201
 
-    info_api = 
'http://vv.video.qq.com/getinfo?otype=json&appver=3.2.19.333&platform=11&defnpayver=1&defn=shd&vid={}'.format(vid)
-    info = get_content(info_api)
-    video_json = json.loads(match1(info, r'QZOutputJson=(.*)')[:-1])
+def qq_download_by_vid(vid, title, output_dir='.', merge=True, 
info_only=False):
 
+    # http://v.sports.qq.com/#/cover/t0fqsm1y83r8v5j/a0026nvw5jr 
https://v.qq.com/x/cover/t0fqsm1y83r8v5j/a0026nvw5jr.html
+    video_json = None
+    platforms = [4100201, 11]
+    for platform in platforms:
+        info_api = 
'http://vv.video.qq.com/getinfo?otype=json&appver=3.2.19.333&platform={}&defnpayver=1&defn=shd&vid={}'.format(platform,
 vid)
+        info = get_content(info_api)
+        video_json = json.loads(match1(info, r'QZOutputJson=(.*)')[:-1])
+        if not video_json.get('msg')=='cannot play outside':
+            break
     fn_pre = video_json['vl']['vi'][0]['lnk']
     title = video_json['vl']['vi'][0]['ti']
     host = video_json['vl']['vi'][0]['ul']['ui'][0]['url']
-    streams = video_json['fl']['fi']
     seg_cnt = fc_cnt = video_json['vl']['vi'][0]['cl']['fc']
 
     filename = video_json['vl']['vi'][0]['fn']
@@ -32,8 +29,6 @@
     else:
         fn_pre, magic_str, video_type = filename.split('.')
 
-    best_quality = streams[-1]['name']
-
     part_urls= []
     total_size = 0
     for part in range(1, seg_cnt+1):
@@ -112,7 +107,6 @@
 
 def qq_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
     """"""
-    default_from = True
 
     if re.match(r'https?://egame.qq.com/live\?anchorid=(\d+)', url):
         from . import qq_egame
@@ -136,10 +130,18 @@
         content = get_content(url)
         vids = matchall(content, [r'\?vid=(\w+)'])
         for vid in vids:
-            qq_download_by_vid(vid, vid, default_from, output_dir, merge, 
info_only)
+            qq_download_by_vid(vid, vid, output_dir, merge, info_only)
         return
 
-    if 'kuaibao.qq.com' in url or 
re.match(r'http://daxue.qq.com/content/content/id/\d+', url):
+    if 'kuaibao.qq.com/s/' in url:
+        # https://kuaibao.qq.com/s/20180521V0Z9MH00
+        nid = match1(url, r'/s/([^/&?#]+)')
+        content = get_content('https://kuaibao.qq.com/getVideoRelate?id=' + 
nid)
+        info_json = json.loads(content)
+        vid=info_json['videoinfo']['vid']
+        title=info_json['videoinfo']['title']
+    elif 'kuaibao.qq.com' in url or 
re.match(r'http://daxue.qq.com/content/content/id/\d+', url):
+        # http://daxue.qq.com/content/content/id/2321
         content = get_content(url)
         vid = match1(content, r'vid\s*=\s*"\s*([^"]+)"')
         title = match1(content, r'title">([^"]+)</p>')
@@ -148,6 +150,11 @@
         vid = match1(url, r'\bvid=(\w+)')
         # for embedded URLs; don't know what the title is
         title = vid
+    elif 'view.inews.qq.com' in url:
+        # view.inews.qq.com/a/20180521V0Z9MH00
+        content = get_content(url)
+        vid = match1(content, r'"vid":"(\w+)"')
+        title = match1(content, r'"title":"(\w+)"')
     else:
         content = get_content(url)
         #vid = parse_qs(urlparse(url).query).get('vid') #for links specified 
vid  like http://v.qq.com/cover/p/ps6mnfqyrfo7es3.html?vid=q0181hpdvo5
@@ -167,12 +174,8 @@
         title = match1(content, r'"title":"([^"]+)"') if not title else title
         title = vid if not title else title #general fallback
 
-        if 'v.sports.qq.com' in url:
-            # fix url forbidden
-            # 
example:http://v.sports.qq.com/#/cover/t0fqsm1y83r8v5j/a0026nvw5jr
-            default_from = False
 
-    qq_download_by_vid(vid, title, default_from, output_dir, merge, info_only)
+    qq_download_by_vid(vid, title, output_dir, merge, info_only)
 
 site_info = "QQ.com"
 download = qq_download
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/extractors/twitter.py 
new/you-get-0.4.1120/src/you_get/extractors/twitter.py
--- old/you-get-0.4.1099/src/you_get/extractors/twitter.py      2018-06-27 
23:35:15.000000000 +0200
+++ new/you-get-0.4.1120/src/you_get/extractors/twitter.py      2018-08-08 
17:12:11.000000000 +0200
@@ -64,42 +64,26 @@
                               output_dir=output_dir)
 
     except: # extract video
-        # always use i/cards or videos url
-        if not re.match(r'https?://twitter.com/i/', url):
-            url = r1(r'<meta\s*property="og:video:url"\s*content="([^"]+)"', 
html)
-            if not url:
-                url = 'https://twitter.com/i/videos/%s' % item_id
-            try:
-                html = get_content(url)
-            except:
-                return
+        #i_url = 'https://twitter.com/i/videos/' + item_id
+        #i_content = get_content(i_url)
+        #js_url = r1(r'src="([^"]+)"', i_content)
+        #js_content = get_content(js_url)
+        #authorization = r1(r'"(Bearer [^"]+)"', js_content)
+        authorization = 'Bearer 
AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA'
 
-        data_config = r1(r'data-config="([^"]*)"', html) or \
-            r1(r'data-player-config="([^"]*)"', html)
-        i = json.loads(unescape_html(data_config))
-        if 'video_url' in i:
-            source = i['video_url']
-            item_id = i['tweet_id']
-            page_title = "{} [{}]".format(screen_name, item_id)
-        elif 'playlist' in i:
-            source = i['playlist'][0]['source']
-            if not item_id: page_title = i['playlist'][0]['contentId']
-        elif 'vmap_url' in i:
-            vmap_url = i['vmap_url']
-            vmap = get_content(vmap_url)
-            source = r1(r'<MediaFile>\s*<!\[CDATA\[(.*)\]\]>', vmap)
-            item_id = i['tweet_id']
-            page_title = "{} [{}]".format(screen_name, item_id)
-        elif 'scribe_playlist_url' in i:
-            scribe_playlist_url = i['scribe_playlist_url']
-            return vine_download(scribe_playlist_url, output_dir, merge=merge, 
info_only=info_only)
+        ga_url = 'https://api.twitter.com/1.1/guest/activate.json'
+        ga_content = post_content(ga_url, headers={'authorization': 
authorization})
+        guest_token = json.loads(ga_content)['guest_token']
 
-        try:
-            urls = extract_m3u(source)
-        except:
-            urls = [source]
+        api_url = 
'https://api.twitter.com/2/timeline/conversation/%s.json?tweet_mode=extended' % 
item_id
+        api_content = get_content(api_url, headers={'authorization': 
authorization, 'x-guest-token': guest_token})
+
+        info = json.loads(api_content)
+        variants = 
info['globalObjects']['tweets'][item_id]['extended_entities']['media'][0]['video_info']['variants']
+        variants = sorted(variants, key=lambda kv: kv.get('bitrate', 0))
+        urls = [ variants[-1]['url'] ]
         size = urls_size(urls)
-        mime, ext = 'video/mp4', 'mp4'
+        mime, ext = variants[-1]['content_type'], 'mp4'
 
         print_info(site_info, page_title, mime, size)
         if not info_only:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/extractors/yixia.py 
new/you-get-0.4.1120/src/you_get/extractors/yixia.py
--- old/you-get-0.4.1099/src/you_get/extractors/yixia.py        2018-06-27 
23:35:15.000000000 +0200
+++ new/you-get-0.4.1120/src/you_get/extractors/yixia.py        2018-08-08 
17:12:11.000000000 +0200
@@ -51,10 +51,10 @@
         yixia_download_by_scid = yixia_miaopai_download_by_scid
         site_info = "Yixia Miaopai"
 
-        scid = match1(url, r'miaopai\.com/show/channel/(.+)\.htm') or \
-               match1(url, r'miaopai\.com/show/(.+)\.htm') or \
-               match1(url, r'm\.miaopai\.com/show/channel/(.+)\.htm') or \
-               match1(url, r'm\.miaopai\.com/show/channel/(.+)')
+        scid = match1(url, r'miaopai\.com/show/channel/([^.]+)\.htm') or \
+               match1(url, r'miaopai\.com/show/([^.]+)\.htm') or \
+               match1(url, r'm\.miaopai\.com/show/channel/([^.]+)\.htm') or \
+               match1(url, r'm\.miaopai\.com/show/channel/([^.]+)')
 
     elif 'xiaokaxiu.com' in hostname:  #Xiaokaxiu
         yixia_download_by_scid = yixia_xiaokaxiu_download_by_scid
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/util/fs.py 
new/you-get-0.4.1120/src/you_get/util/fs.py
--- old/you-get-0.4.1099/src/you_get/util/fs.py 2018-06-27 23:35:15.000000000 
+0200
+++ new/you-get-0.4.1120/src/you_get/util/fs.py 2018-08-08 17:12:11.000000000 
+0200
@@ -1,8 +1,8 @@
 #!/usr/bin/env python
 
-import platform
+from .os import detect_os
 
-def legitimize(text, os=platform.system()):
+def legitimize(text, os=detect_os()):
     """Converts a string to a valid filename.
     """
 
@@ -13,7 +13,7 @@
         ord('|'): '-',
     })
 
-    if os == 'Windows':
+    if os == 'windows' or os == 'cygwin' or os == 'wsl':
         # Windows (non-POSIX namespace)
         text = text.translate({
             # Reserved in Windows VFAT and NTFS
@@ -31,7 +31,7 @@
         })
     else:
         # *nix
-        if os == 'Darwin':
+        if os == 'mac':
             # Mac OS HFS+
             text = text.translate({
                 ord(':'): '-',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/util/os.py 
new/you-get-0.4.1120/src/you_get/util/os.py
--- old/you-get-0.4.1099/src/you_get/util/os.py 1970-01-01 01:00:00.000000000 
+0100
+++ new/you-get-0.4.1120/src/you_get/util/os.py 2018-08-08 17:12:11.000000000 
+0200
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+from platform import system
+
+def detect_os():
+    """Detect operating system.
+    """
+
+    # Inspired by:
+    # 
https://github.com/scivision/pybashutils/blob/78b7f2b339cb03b1c37df94015098bbe462f8526/pybashutils/windows_linux_detect.py
+
+    syst = system().lower()
+    os = 'unknown'
+
+    if 'cygwin' in syst:
+        os = 'cygwin'
+    elif 'darwin' in syst:
+        os = 'mac'
+    elif 'linux' in syst:
+        os = 'linux'
+        # detect WSL https://github.com/Microsoft/BashOnWindows/issues/423
+        with open('/proc/version', 'r') as f:
+            if 'microsoft' in f.read().lower():
+                os = 'wsl'
+    elif 'windows' in syst:
+        os = 'windows'
+    elif 'bsd' in syst:
+        os = 'bsd'
+
+    return os
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/src/you_get/version.py 
new/you-get-0.4.1120/src/you_get/version.py
--- old/you-get-0.4.1099/src/you_get/version.py 2018-06-27 23:35:15.000000000 
+0200
+++ new/you-get-0.4.1120/src/you_get/version.py 2018-08-08 17:12:11.000000000 
+0200
@@ -1,4 +1,4 @@
 #!/usr/bin/env python
 
 script_name = 'you-get'
-__version__ = '0.4.1099'
+__version__ = '0.4.1120'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/you-get-0.4.1099/tests/test_util.py 
new/you-get-0.4.1120/tests/test_util.py
--- old/you-get-0.4.1099/tests/test_util.py     2018-06-27 23:35:15.000000000 
+0200
+++ new/you-get-0.4.1120/tests/test_util.py     2018-08-08 17:12:11.000000000 
+0200
@@ -6,6 +6,7 @@
 
 class TestUtil(unittest.TestCase):
     def test_legitimize(self):
-        self.assertEqual(legitimize("1*2", os="Linux"), "1*2")
-        self.assertEqual(legitimize("1*2", os="Darwin"), "1*2")
-        self.assertEqual(legitimize("1*2", os="Windows"), "1-2")
+        self.assertEqual(legitimize("1*2", os="linux"), "1*2")
+        self.assertEqual(legitimize("1*2", os="mac"), "1*2")
+        self.assertEqual(legitimize("1*2", os="windows"), "1-2")
+        self.assertEqual(legitimize("1*2", os="wsl"), "1-2")


Reply via email to