Пример #1
0
def main():
    parser = optparse.OptionParser(usage='%prog VERSION BUILDPATH')
    options, args = parser.parse_args()
    if len(args) != 2:
        parser.error('Expected a version and a build directory')

    version, build_path = args

    releaser = GitHubReleaser()

    new_release = releaser.create_release(version, name='youtube-dl %s' % version)
    release_id = new_release['id']

    for asset in os.listdir(build_path):
        compat_print('Uploading %s...' % asset)
        releaser.create_asset(release_id, os.path.join(build_path, asset))
def main():
    parser = optparse.OptionParser(usage='%prog CHANGELOG VERSION BUILDPATH')
    options, args = parser.parse_args()
    if len(args) != 3:
        parser.error('Expected a version and a build directory')

    changelog_file, version, build_path = args

    with io.open(changelog_file, encoding='utf-8') as inf:
        changelog = inf.read()

    mobj = re.search(r'(?s)version %s\n{2}(.+?)\n{3}' % version, changelog)
    body = mobj.group(1) if mobj else ''

    releaser = GitHubReleaser()

    new_release = releaser.create_release(
        version, name='youtube-dl %s' % version, body=body)
    release_id = new_release['id']

    for asset in os.listdir(build_path):
        compat_print('Uploading %s...' % asset)
        releaser.create_asset(release_id, os.path.join(build_path, asset))
Пример #3
0
def main():
    parser = optparse.OptionParser(usage='%prog CHANGELOG VERSION BUILDPATH')
    options, args = parser.parse_args()
    if len(args) != 3:
        parser.error('Expected a version and a build directory')

    changelog_file, version, build_path = args

    with io.open(changelog_file, encoding='utf-8') as inf:
        changelog = inf.read()

    mobj = re.search(r'(?s)version %s\n{2}(.+?)\n{3}' % version, changelog)
    body = mobj.group(1) if mobj else ''

    releaser = GitHubReleaser()

    new_release = releaser.create_release(
        version, name='youtube-dl %s' % version, body=body)
    release_id = new_release['id']

    for asset in os.listdir(build_path):
        compat_print('Uploading %s...' % asset)
        releaser.create_asset(release_id, os.path.join(build_path, asset))
 def _init_github_account(self):
     try:
         info = netrc.netrc().authenticators(self._NETRC_MACHINE)
         if info is not None:
             self._token = info[2]
             compat_print('Using GitHub credentials found in .netrc...')
             return
         else:
             compat_print('No GitHub credentials found in .netrc')
     except (IOError, netrc.NetrcParseError):
         compat_print('Unable to parse .netrc')
     self._token = compat_getpass(
             'Type your GitHub username or email address and press [Return]: ')
Пример #5
0
 def _init_github_account(self):
     try:
         info = netrc.netrc().authenticators(self._NETRC_MACHINE)
         if info is not None:
             self._username = info[0]
             self._password = info[2]
             compat_print('Using GitHub credentials found in .netrc...')
             return
         else:
             compat_print('No GitHub credentials found in .netrc')
     except (IOError, netrc.NetrcParseError):
         compat_print('Unable to parse .netrc')
     self._username = compat_input(
         'Type your GitHub username or email address and press [Return]: ')
     self._password = compat_getpass(
         'Type your GitHub password and press [Return]: ')
def format_size(bytes):
    return '%s (%d bytes)' % (format_bytes(bytes), bytes)


total_bytes = 0

for page in itertools.count(1):
    releases = json.loads(
        compat_urllib_request.urlopen(
            'https://api.github.com/repos/rg3/youtube-dl/releases?page=%s' %
            page).read().decode('utf-8'))

    if not releases:
        break

    for release in releases:
        compat_print(release['name'])
        for asset in release['assets']:
            asset_name = asset['name']
            total_bytes += asset['download_count'] * asset['size']
            if all(not re.match(p, asset_name) for p in (
                    r'^youtube-dl$',
                    r'^youtube-dl-\d{4}\.\d{2}\.\d{2}(?:\.\d+)?\.tar\.gz$',
                    r'^youtube-dl\.exe$')):
                continue
            compat_print(' %s size: %s downloads: %d' %
                         (asset_name, format_size(
                             asset['size']), asset['download_count']))

compat_print('total downloads traffic: %s' % format_size(total_bytes))
def format_size(bytes):
	return '%s (%d bytes)' % (format_bytes(bytes), bytes)


total_bytes = 0

for page in itertools.count(1):
	releases = json.loads(compat_urllib_request.urlopen(
		'https://api.github.com/repos/rg3/youtube-dl/releases?page=%s' % page
	).read().decode('utf-8'))

	if not releases:
		break

	for release in releases:
		compat_print(release['name'])
		for asset in release['assets']:
			asset_name = asset['name']
			total_bytes += asset['download_count'] * asset['size']
			if all(not re.match(p, asset_name) for p in (
				r'^youtube-dl$',
				r'^youtube-dl-\d{4}\.\d{2}\.\d{2}(?:\.\d+)?\.tar\.gz$',
				r'^youtube-dl\.exe$')):
				continue
			compat_print(
				' %s size: %s downloads: %d'
				% (asset_name, format_size(asset['size']), asset['download_count']))

compat_print('total downloads traffic: %s' % format_size(total_bytes))