Skip to content

Instantly share code, notes, and snippets.

@redstoneleo
Created April 11, 2017 15:04
Show Gist options
  • Save redstoneleo/7cb0fff39438a523418bb212967a664e to your computer and use it in GitHub Desktop.
Save redstoneleo/7cb0fff39438a523418bb212967a664e to your computer and use it in GitHub Desktop.
url match
if 'le.com' in sourceUrl and not isYougetParsed: # ykdl解析乐视
videoUrls = re.search(r"Real URLs:\s*(?P<videoUrls>\S*)", parseResult, re.IGNORECASE).group('videoUrls').split() # 搜寻链接,因为有了download-url:,所以必须从Real URLs:后面搜寻,一个本地地址是连续不断的,所以用\S没问题
else:
videoUrls = re.findall(r'''\s*[\[']*(?P<videoUrls>https?://\S*)['\]]*''', parseResult) # 因为url是连续不断的,所以用\S没问题,因为是贪婪模式,并且后面的']可选,所以结果里会有']
videoUrls = list(map(lambda videoUrl: videoUrl.rstrip("']"), videoUrls))
# videoUrlsMatch
# print('videoUrls----------', videoUrlsMatch.group('videoUrls'))
if not all([baseNameMatch, videoUrls]): # 有空结果
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment