| ents += str(blocking)+ ',' | |
| csv_contents += str(blocked_by)+ ',' | |
| csv_contents += str(uptime)+ ',' | |
| csv_contents += str(age)+ ',' | |
| csv_contents += version | |
| csv_contents += "\n" | |
| # write the instance data table to the csv file | |
| with open( OUT_CSV, "w" ) as csv_file: | |
| csv_file.write( csv_contents ) | |
| ######################### | |
| # RECOMMENDED INSTANCES # | |
| ######################### | |
| # shrink the list to just a few recommended instances | |
| all_instances = list() | |
| recommended_instances = list() | |
| with open(OUT_CSV) as csv_file: | |
| for instance in csv.DictReader( csv_file ): | |
| all_instances.append( instance ) | |
| # only include instances that are "yes" across-the-board | |
| if instance['NU'] == "Yes" \ | |
| and instance['NC'] == "Yes" \ | |
| and instance['Fed'] == "Yes" \ | |
| and instance['Adult'] == "Yes" \ | |
| and instance['↓V'] == "Yes": | |
| recommended_instances.append( instance ) | |
| # remove instances with too few or too may users | |
| recommended_instances = [x for x in recommended_instances if int(x['Users']) > 60 and int(x['Users']) < 1000] | |
| # get a lits of all the instances that have more than 1 blocked instance and | |
| # then get the average number of instances that are blocked | |
| try: | |
| bi_list = [ int(x['BI']) for x in all_instances if int(x['BI']) > 1 ] | |
| bi_avg = numpy.average( bi_list ) | |
| except (Exception, RuntimeWarning) as e: | |
| print( "WARNING: Caught numpy exception when calculating bi_avg: " +str(e) ) | |
| bi_avg = 2 | |
| # get a lits of all the instances that are blocked by more than 1 instance and | |
| # then get the average number of that instances are are blocked | |
| try: | |
| bb_list = [ int(x['BB']) for x in all_instances if int(x['BB']) > 1 ] | |
| bb_avg = numpy.average( bb_list ) | |
| except (Exception, RuntimeWarning) as e: | |
| print( "WARNING: Caught numpy exception when calculating bb_avg: " +str(e) ) | |
| bb_avg = 2 | |
| print( "bi_avg:|" +str(bi_avg)+ "|" ) | |
| print( "bb_avg:|" +str(bb_avg)+ "|" ) | |
| # remove instances that are blocking or blocked-by too many other instancesk | |
| recommended_instances = [ x for x in recommended_instances if int(x['BI']) <= bi_avg and int(x['BB']) <= bb_avg ] | |
| # remove instances that haven't been online for 2 months | |
| recommended_instances = [ x for x in recommended_instances if int(x['MO']) >= 2 ] | |
| # limit to those with the best uptime; first we make sure that we actually | |
| # have the uptime data | |
| uptime_available = [x for x in recommended_instances if x['UT'] != '??'] | |
| # do we have uptime data? | |
| if uptime_available != list(): | |
| # we have uptime data; proceed with reducing the set of recommended_instances | |
| # based on uptime | |
| # loop down from 100% to 0% | |
| for percent_uptime in reversed(range(100)): | |
| high_uptime_instances = [x for x in recommended_instances if x['UT'] != '??' and int(x['UT'][:-1]) > percent_uptime] | |
| # do we have more than one instance above this uptime? | |
| if len(high_uptime_instances) > 1: | |
| # we already have enough instances; ignore the rest with lower uptime | |
| recommended_instances = high_uptime_instances | |
| break | |
| # prepare data for csv file | |
| csv_contents = "Instance,NU,NC,Fed,Adult,↓V,Users,BI,BB,UT,MO,Version\n" | |
| for instance in recommended_instances: | |
| csv_contents += instance['Instance']+ ',' | |
| csv_contents += instance['NU']+ ',' | |
| csv_contents += instance['NC']+ ',' | |
| csv_contents += instance['Fed']+ ',' | |
| csv_contents += instance['Adult']+ ',' | |
| csv_contents += instance['↓V']+ ',' | |
| csv_contents += instance['Users']+ ',' | |
| csv_contents += instance['BI']+ ',' | |
| csv_contents += instance['BB']+ ',' | |
| csv_contents += instance['UT']+ ',' | |
| csv_contents += instance['MO']+ ',' | |
| csv_contents += instance['Version'] | |
| csv_contents += "\n" | |
| # write the recommended instance data table to a csv file | |
| with open( 'recommended-instances.csv', "w" ) as csv_file: | |
| csv_file.write( csv_contents ) | |
| # convert csv file data to markdown table | |
| df = pd.read_csv( 'recommended-instances.csv' ) | |
| recommended_markdown_table = df.to_markdown( tablefmt='pipe', index = False ) | |
| # add newline to protect the table from getting klobbered by the text around it | |
| recommended_markdown_table = "\n" + recommended_markdown_table + "\n" | |
| readme_contents += """ | |
| # Recommended Instances | |
| Just **click on a random instance** from the below "recommended" instances. | |
| Don't overthink this. **It doesn't matter which instance you use.** You'll still be able to interact with communities (subreddits) on all other instances, regardless of which instance your account lives 🙂 | |
| """ | |
| # add the markdown table to the readme's contents | |
| readme_contents += recommended_markdown_table | |
| readme_contents += """ | |
| # What's next? | |
| ## Subscribe to ~~Subreddits~~ Communities | |
| After you pick an instance and register an account, you'll want to subscribe to communities. You can subscribe to "local" communities on your instance, and (if you chose an instance that isn't siloed) you can also subscribe to "remote" communities on other instances. | |
| To **find popular communities** across all lemmy instances in the fediverse, you can use the [Lemmy Community Browser](https://browse.feddit.de/) run by feddit.de. | |
| * https://browse.feddit.de/ | |
| If you want a more direct mapping of your favorite /r/subreddits to lemmy, checkout these sites: | |
| 1. [redditmigration.com](https://redditmigration.com/) | |
| 1. [sub.rehab](https://sub.rehab/?searchTerm=&visibleServices=lemmy&officialOnly=false&newOnly=false&favoriteOnly=false&sortBy=users_active_week) | |
| 1. yoasif's [Unofficial Subreddit Migration List](https://www.quippd.com/writing/2023/06/15/unofficial-subreddit-migration-list-lemmy-kbin-etc.html) | |
| <a href="https://tech.michaelaltfield.net/2023/06/11/lemmy-migration-find-subreddits-communities/"><img src="lemmy-migration-find-subreddits-communities.jpg" alt="How To Find Lemmy Communities" /></ |