예제 #1
0
    def pbrtle(self):
        tracks = []

        def igc_lambda(self, index):
            return lambda: self.ipbrtr(index)

        for m in self.ieach('PBRTLE,', PBRTLE_RE, 0.5):
            index = int(m.group(2))
            day, month, year, hour, minute, second = (int(i)
                                                      for i in m.groups()[2:8])
            hours, minutes, seconds = (int(i) for i in m.groups()[8:11])
            tracks.append(
                Track(count=int(m.group(1)),
                      index=index,
                      datetime=datetime.datetime(year + 2000,
                                                 month,
                                                 day,
                                                 hour,
                                                 minute,
                                                 second,
                                                 tzinfo=UTC()),
                      duration=datetime.timedelta(hours=hours,
                                                  minutes=minutes,
                                                  seconds=seconds),
                      max_a1=int(m.group(12)),
                      max_a2=int(m.group(13)),
                      max_a3=int(m.group(14)),
                      scan_rate=int(m.group(15)),
                      _igc_lambda=igc_lambda(self, index)))
        return add_igc_filenames(tracks, self.manufacturer, self.serial_number)
예제 #2
0
    def pfmdnl_lst(self):
        tracks = []

        def igc_lambda(self, dt):
            return lambda: self.igc_helper(self.ipfmdnl(dt))

        for m in self.ieach('PFMDNL,LST,', PFMDNL_LST_RE):
            count, index, day, month, year, hour, minute, second = map(
                int,
                m.groups()[:8])
            hours, minutes, seconds = map(int, m.groups()[8:11])
            dt = datetime.datetime(year + 2000,
                                   month,
                                   day,
                                   hour,
                                   minute,
                                   second,
                                   tzinfo=UTC())
            tracks.append(
                Track(index=index,
                      datetime=dt,
                      duration=datetime.timedelta(hours=hours,
                                                  minutes=minutes,
                                                  seconds=seconds),
                      _igc_lambda=igc_lambda(self, dt)))
            if index + 1 == count:
                break
        return add_igc_filenames(tracks, 'XFR', self.serial_number)
예제 #3
0
    def act20(self):
        self.write('ACT_20_00\r\n')
        line = self.readline(0.5)
        if re.match('\A\s*No\s+Data\s*\r\n\Z', line):
            return []
        tracks = []

        def igc_lambda(self, index):
            return lambda: self.iact21(index)

        while True:
            if line == ' Done\r\n':
                break
            fields = re.split(r'\s*;\s*', line)
            index = int(fields[0])
            year, month, day = (int(x) for x in fields[1].split('.'))
            hour, minute, second = (int(x) for x in fields[2].split(':'))
            hours, minutes, seconds = (int(x) for x in fields[4].split(':'))
            tracks.append(
                Track(index=index,
                      datetime=datetime.datetime(year + 2000,
                                                 month,
                                                 day,
                                                 hour,
                                                 minute,
                                                 second,
                                                 tzinfo=UTC()),
                      utc_offset=int(fields[3]),
                      duration=datetime.timedelta(seconds=3600 * hours +
                                                  60 * minutes + seconds),
                      altitude_offset=int(fields[5]),
                      altitude_max=int(fields[6]),
                      altitude_min=int(fields[7]),
                      vario_max=float(fields[8]),
                      vario_min=float(fields[9]),
                      speed_max=float(fields[10]),
                      pilot_name=fields[11].strip(),
                      glider_type=fields[12].strip(),
                      glider_id=fields[13].strip(),
                      _igc_lambda=igc_lambda(self, index)))
            line = self.readline(0.5)
        return add_igc_filenames(tracks, self.manufacturer[:3].upper(),
                                 self.serial_number)
예제 #4
0
def try_get_song_from_db(song_id):
    if song_id in tracks_cache:
        return tracks_cache[song_id]
    result_set = get_conn().cursor().execute("""
    SELECT TrackInfo FROM Tracks Where Id = ?
    """, [song_id])
    row = result_set.fetchone()
    if row:
        json_obj, = row
        track = Track.from_json(json_obj)
        artists, remains = try_get_artists_from_db(track.artists)
        if remains:
            remain_artists = [get_similar_artists(artist_id) for artist_id in remains]
            for artist in remain_artists:
                if not artist:
                    return None
            put_artists_to_db(remain_artists)
            artists.extend(remain_artists)
            remains.clear()
        assert (not remains)
        track.artists = artists
        tracks_cache[track.id] = track
        return track
예제 #5
0
from metadata import Metadata


print(logo)
meta = Metadata()
print("version " + meta.get_version() + "\n")


def add_source(m3u_file, track):
    prettified_title = track.title.replace("-", " ")
    prettified_title = prettified_title.replace(".m3u", "")
    source = "#EXTINF:" + str(track.length) + "," + prettified_title + "\n"
    source = source + track.path + "\n"
    m3u_file += source

    return m3u_file


for genre in genres:
    files = get_files(genre)
    m3u_file = "#EXTM3U\n"
    for file in files:
        track = Track(-1, file, (repo_base_url + "/" + genre + "/" + file))
        m3u_file = add_source(m3u_file, track)

    file = open("../" + genre + "/" + "ALL_" + genre + ".m3u", "w")
    file.write(m3u_file)
    file.close()
    print("ALL_" + genre + ".m3u" + " saved!")
    m3u_file = ""