from ftplib import FTP
import os
def discover_cdn1_ftp(host, path='/', depth=0, max_depth=5):
if depth > max_depth:
return []
ftp = FTP(host)
ftp.login(user='anonymous', passwd='discovery@') # often anonymous on public CDNs
ftp.cwd(path)
discovered = []
try:
items = ftp.nlst() # NLST is faster for discovery
for item in items:
full_path = f"path/item" if path != '/' else f"/item"
try:
ftp.cwd(item) # if succeeds, it's a directory
discovered.extend(discover_cdn1_ftp(host, full_path, depth+1, max_depth))
ftp.cwd('..')
except:
# it's a file
size = ftp.size(item)
discovered.append('path': full_path, 'size': size)
except Exception as e:
print(f"Discovery error at path: e")
finally:
ftp.quit()
return discovered
filename,filesize,sha256,asset_id,ingest_date
video_title_1080p.mp4,1250000000,abcdef1234...,ASSET123,2026-04-09 cdn1discovery ftp work
Discovery, in the FTP context, is the process of listing, crawling, or identifying files available on an FTP server without prior knowledge of their exact paths or names. Unlike HTTP directory indexing (which can be disabled), FTP’s LIST and NLST commands allow automated clients to recursively traverse directories, making it a primitive but effective discovery protocol. from ftplib import FTP import os def discover_cdn1_ftp(host,
Listed contents:
ls -la
Notable files/directories: